View Single Post
  #4  
Old 21-10-2010, 10:49 PM
mithrandir's Avatar
mithrandir (Andrew)
Registered User

mithrandir is offline
 
Join Date: Jan 2009
Location: Glenhaven
Posts: 4,161
The traditional C method of doing a sleep with granularity less than 1 second is to use select() with the three fd_sets all being empty and the struct timeval being the required seconds and microseconds.

Code:
       int select(int nfds, fd_set *readfds, fd_set *writefds,
                  fd_set *exceptfds, struct timeval *timeout);
Note that sleep(1) is only guaranteed to sleep to the top of the next second, so not more than one second.
Reply With Quote