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
USLEEP(3)						   BSD Library Functions Manual 						 USLEEP(3)

NAME
usleep -- suspend thread execution for an interval measured in microseconds LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <unistd.h> int usleep(useconds_t useconds); DESCRIPTION
The usleep() function suspends execution of the calling thread until either useconds microseconds have elapsed or a signal is delivered to the thread whose action is to invoke a signal-catching function or to terminate the thread or process. The actual time slept may be longer, due to system latencies and possible limitations in the timer resolution of the hardware. This function is implemented, using nanosleep(2), by pausing for useconds microseconds or until a signal occurs. Consequently, in this implementation, sleeping has no effect on the state of process timers and there is no special handling for SIGALRM. RETURN VALUES
The usleep() function returns the value 0 if successful; otherwise the value -1 is returned and the global variable errno is set to indicate the error. ERRORS
The usleep() function will fail if: [EINTR] A signal was delivered to the process and its action was to invoke a signal-catching function. SEE ALSO
nanosleep(2), sleep(3) HISTORY
The usleep() function appeared in 4.3BSD. BSD
February 13, 1998 BSD
All times are GMT -4. The time now is 11:11 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy