www.delorie.com/djgpp/bugs/show.cgi | search |
#include <unistd.h> main() { int loop; for (loop=0; loop<=20; loop++) { printf("%10d\n",loop); // These print with a delay usleep(11264); } printf("%s\n","----------------------------------"); for (loop=0; loop<=20; loop++) { printf("%10d\n",loop); // These print with no delay!!!! usleep(11263); } } }
This is not a bug: `usleep' uses `clock' internally, and so has only 55-msec granularity. Since `clock' reports the timer tick count with a scale factor of 5, any argument to `usleep' that is less than 11 msec will result in no sleep at all, and anything less than 55 msec will sometimes sleep for 55 msec and sometimes for less. A note in this spirit wass added in WIP and will be in v2.03.
webmaster | delorie software privacy |
Copyright © 2010 by DJ Delorie | Updated Jul 2010 |