Link to home
Start Free TrialLog in
Avatar of yury1854
yury1854

asked on

Delay Function

Hi,

I was wondering if there are any delay or sleep function under linux. I need delays of around several milliseconds. I have tried nanosleep, but that does not seem to work very well and does not give pauses for the desired amounts of time. Whenever I tell it to pause for a few seconds it works more or less, but when I tell it to pause for a large amount on nanoseconds it does not pause at all. Are there any alternatives?
Avatar of akshayxx
akshayxx
Flag of United States of America image

use sleep() to sleep for 'seconds'
and usleep() to sleep for "micro seconds"
the delay that sleep gives is quite noticable.
more than 3-4 seconds is rather irritating.
Avatar of yury1854
yury1854

ASKER

What do I need to include for usleep()? <time.h> does not seem to have it.
ASKER CERTIFIED SOLUTION
Avatar of akshayxx
akshayxx
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Okay, I've got a weirdness w/ my Linux system then. Whenever I request the time in milliseconds or smaller, it give me 0. This might be because the machine I am trying this on is a P133 w/ Red Hat 5.2. I'll accept the usleep include file as the answer, but if anyone has any suggestions, please tell me. Thank you.
>>>Whenever I request the time in milliseconds or smaller, it give me 0

what function call u make .. ?
ftime(timeb *);