On Feb 3, 2007, at 7:21 AM, Colin Hirsch wrote:
10 milliseconds is quite feasible, corrresponds to a timer tick of 100 Hz, which is quite common... Quick test on a 2.4.18 box gives me the following; seems to be running 50 Hz (or is under some load):
...snip... real 0m2.002s user 0m0.000s sys 0m0.010s
For comparison the same test on a Mac Pro (and with WoW running in the background). It sure looks like Mac OS X is more closely honoring your sleep request then Linux is.
MacPro:~ shawnce$ cat t.cc #include <time.h>
int main( int argc, char ** argv ) { timespec t = { 0, 1 };
for ( unsigned i = 0; i < 100; ++i ) ::nanosleep( & t, 0 );
return 0; } MacPro:~ shawnce$ g++ -O t.cc MacPro:~ shawnce$ time ./a.out
real 0m0.016s user 0m0.001s sys 0m0.004s
Greg, it looks like your comparison isn't correctly accounting for the difference in time actually slept by each platform. It sounds like your code when run on Linux is sleeping a lot longer then you are actually asking it to sleep... so if you product works on Linux with a sleep period around 10ms I suggest you request a longer sleep time to begin with.
Also one has to ask... you appear to be polling, can you avoid that polling to begin with?
-Shawn
|