mrcool4444
asked on
Linux timer (sleep, delay, pause, etc) function
I have a set of processes that I want done in an infinate loop. Obviously if I put them into an actual loop, I will get 100% cpu usage (not acceptable). A funtion that stoppes the loops for about a minute should (I am hoping) solve this problem. The code must work in linux.
Example of what I need:
do
{
reload();
bandwith();
fileload();
filewrite();
}
while (FOREVER);
But, the above needs to be done every minute in a loop. So I think something like do { timer(1minutes) } while (FOREVER) would solve this problem.
Example of what I need:
do
{
reload();
bandwith();
fileload();
filewrite();
}
while (FOREVER);
But, the above needs to be done every minute in a loop. So I think something like do { timer(1minutes) } while (FOREVER) would solve this problem.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
welcome .. btw u could have tried
man sleep
man 3 sleep
actually man sleep will give u the manual page for command line 'sleep'
usually library functions' man pages are in 2nd 3rd sections
any ways good to know it worked for u
man sleep
man 3 sleep
actually man sleep will give u the manual page for command line 'sleep'
usually library functions' man pages are in 2nd 3rd sections
any ways good to know it worked for u
ASKER
man 3 sleep did it :)
ASKER
I did manage to find that sleep() was located in unistd.h.
Everything works great now (except for the man page).
Thanks!