Sponsored Content
Top Forums Programming Problem with timely execution of threads... Post 302587938 by Corona688 on Friday 6th of January 2012 10:33:31 AM
Old 01-06-2012
If you put your ASCII art inside
Code:
code tags

it will come out like you were expecting.

Unless you've got enough cores to have one free for each and every individual client, they literally can't execute simultaneously. By necessity, they take turns. Hopefully that doesn't matter to you.

I presume you're making the threads wait with something like usleep() ? Remember that sleep, usleep, etc may wait more or less time than you were expecting -- and that sleeping two minutes won't make you run every 2 minutes, since the rest your code takes a little time to run too. You should check gettimeofday() to see how long you need to rest. You should also give each thread an identical starting number to measure against, so they're all aiming for the same 2-minute mark.

A better way to do this would be for the app server to signal your clients with a mutex, semaphore, cond, or the like every time two minutes, and have the server tell them when they were supposed to have been woken up.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl v5.8.5 Threads Problem

Hi Unix gurus, I am facing a threading problem in Perl. I have a worker thread in perl in which I am calling a shell script. The shell script echo's output to the Standard Output from time to time as it progresses. In the worker thread, I am unable to display the echo statement of shell... (1 Reply)
Discussion started by: som.nitk
1 Replies

2. HP-UX

%Internal DCE Threads problem (version CMA BL10+)

Hi, I have a module by the name gateway, and it core dumps and gives a cma_dump.log file which says: %Internal DCE Threads problem (version CMA BL10+), terminating execution. % Reason: dispatch: no available VP (uniprocessor) The current thread is 3 (address 0x40107c40) DECthreads... (0 Replies)
Discussion started by: vanz
0 Replies

3. Programming

problem with threads in C

I have problem that if I create for example 100 threads program work correctly but if I define more threads for example 1000 // if I change static int NUM_E from 100 to 1000 than program stop about 350 threads and doesn't continue where should be problem please? #include <pthread.h>... (4 Replies)
Discussion started by: Sevco777
4 Replies

4. UNIX for Dummies Questions & Answers

execution problem

Hi i am using expect module and trying to login using following code. ssh 127.0.0.1 expect "word:" send "$password \n" kindly let me know the login script using expect module (1 Reply)
Discussion started by: esumiba
1 Replies

5. UNIX for Dummies Questions & Answers

execution problem

Hi i have a file in which there are three fields code: 919804199233 404911130003916 357266044991350F and now i want to add two more fields i.e. code: 919804199233 404911130003916 357266044991350F ms 123 how can i do it using command line and if have a file of 100... (8 Replies)
Discussion started by: esumiba
8 Replies

6. UNIX for Dummies Questions & Answers

execution problem

Hi I am automating my few commands out of which one command is tail -f running.logs when i run this command it does not automatically exit and show prompt (#) what would i do so that it will exit out automatically after few seconds and move to the next command without using ... (4 Replies)
Discussion started by: esumiba
4 Replies

7. UNIX for Dummies Questions & Answers

execution problem

HI I am trying to check the status of port using command /code: netstat -an | grep port /Output: *.2009 *.* 0 0 65535 0 LISTEN what i am trying to do is i want to grep only status Wether the port is established/listen if so show ok else... (1 Reply)
Discussion started by: esumiba
1 Replies

8. Shell Programming and Scripting

Execution problem

hi all, when i tried executing the script by giving following command $ sh test.sh <parameter> it shows the following output: <none> status code=0 Previously it was working fine.But now its showing this output. (1 Reply)
Discussion started by: sanjay mn
1 Replies

9. Shell Programming and Scripting

Execution problem

Hi, I have been trying to run a simple script CONFIG_FILE="/jay/check" . . . for i in `cat $CONFIG_FILE` do loc=`echo $i | cut -d "|" -f2` var=$(find $loc -mtime -1|wc -l) if then echo $loc has files older than 1 day fi done . . . (2 Replies)
Discussion started by: jayii
2 Replies

10. Shell Programming and Scripting

Help needed: script for timely average from log file

Please repost your query: Help needed: script for timely average from log file - Thank you. (0 Replies)
Discussion started by: mkfs
0 Replies
XInitThreads(3) 						  XLIB FUNCTIONS						   XInitThreads(3)

NAME
XInitThreads, XLockDisplay, XUnlockDisplay - multi-threading support SYNTAX
Status XInitThreads(void); void XLockDisplay(Display *display); void XUnlockDisplay(Display *display); ARGUMENTS
display Specifies the connection to the X server. DESCRIPTION
The XInitThreads function initializes Xlib support for concurrent threads. This function must be the first Xlib function a multi-threaded program calls, and it must complete before any other Xlib call is made. This function returns a nonzero status if initialization was suc- cessful; otherwise, it returns zero. On systems that do not support threads, this function always returns zero. It is only necessary to call this function if multiple threads might use Xlib concurrently. If all calls to Xlib functions are protected by some other access mechanism (for example, a mutual exclusion lock in a toolkit or through explicit client programming), Xlib thread ini- tialization is not required. It is recommended that single-threaded programs not call this function. The XLockDisplay function locks out all other threads from using the specified display. Other threads attempting to use the display will block until the display is unlocked by this thread. Nested calls to XLockDisplay work correctly; the display will not actually be unlocked until XUnlockDisplay has been called the same number of times as XLockDisplay. This function has no effect unless Xlib was successfully initialized for threads using XInitThreads. The XUnlockDisplay function allows other threads to use the specified display again. Any threads that have blocked on the display are allowed to continue. Nested locking works correctly; if XLockDisplay has been called multiple times by a thread, then XUnlockDisplay must be called an equal number of times before the display is actually unlocked. This function has no effect unless Xlib was successfully ini- tialized for threads using XInitThreads. SEE ALSO
Xlib - C Language X Interface X Version 11 libX11 1.2.1 XInitThreads(3)
All times are GMT -4. The time now is 03:20 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy