site_archiver@lists.apple.com Delivered-To: darwin-kernel@lists.apple.com It seems this case is closed gentlemen, thank you all for your help! - Greg On Feb 3, 2007, at 10:21 AM, Colin Hirsch wrote: But how accurate is it? When I last dealt with this a few years ago, nanosleep always slept at least 10ms on Linux. Some quick googling shows this still seems to be the case. 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): colin:~$ 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; } colin:~$ g++ -O t.cc colin:~$ time ./a.out real 0m2.002s user 0m0.000s sys 0m0.010s _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-kernel mailing list (Darwin-kernel@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-kernel/site_archiver%40lists.a... Ah... perfect! Thanks for that, I should have tried the "time" command, that is really useful! Our linux machines are running 2.6 kernels and sleeping for 1000 nanos or 1 nano results in a sleep time of 2 milliseconds (apparently they changed this from 2.4). Running my program using that I get a CPU usage of about 3.5%, which is much more acceptable. Finally, running the "time" command on this code in OS X shows that each nanosleep(1) call results in a sleep time of about 50 microseconds. Trying to sleep this amount of time on linux does not work using usleep, it will still sleep for 2 milliseconds each time. On Sat, Feb 03, 2007 at 03:24:15AM -0500, Ed Wynne wrote: On Feb 3, 2007, at 3:03 AM, Jan Brittenson wrote: Greg wrote: So then why do I barely see 1% CPU utilization on linux? I assume you ment 10us? Regards, Colin _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-kernel mailing list (Darwin-kernel@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-kernel/greg% 40kinostudios.com This email sent to greg@kinostudios.com This email sent to site_archiver@lists.apple.com
participants (1)
-
Greg