[an error occurred while processing this directive]
Previous:Reboot the PC,
Q: The function
usleep doesn't work for me! When its
argument is less than 10000, there's no delay at all, and when the
argument is larger than 10000, the delay is always the same....
Q: How can I delay the execution of my program for 2msec?
Q: I need to pause my program for 100 microseconds. Can I do it?
A: Most time-related facilities in DJGPP have the same 55msec
granularity of the time intervals they measure. This is because the
timer tick interrupt that updates the time has the frequency of
18.2Hz. This is why calling
usleep with arguments less
than 55000 produces strange effects: the resolution of the argument is
1usec (for compatibility with other compilers), but the
granularity is still 55msec.
If you need to pause your program for periods of time shorter than 55msec, you have several alternatives:
delay. It is based on the CMOS clock chip whose frequency is 1024Hz.
uclockto see when the pause time expires.
uclockmeasures time with 840-nanosecond granularity. Here's a possible implementation of such a wait loop:
#include <time.h> uclock_t start; /* Wait for 200 microseconds. */ start = uclock (); while (uclock () < start + UCLOCKS_PER_SEC / 5000) ;