• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Sleeping in nanos
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sleeping in nanos


  • Subject: Re: Sleeping in nanos
  • From: Shawn Erickson <email@hidden>
  • Date: Sat, 03 Feb 2007 08:45:06 -0800


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



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Sleeping in nanos
      • From: Greg <email@hidden>
References: 
 >Sleeping in nanos (From: Greg <email@hidden>)
 >Fwd: Sleeping in nanos (From: Greg <email@hidden>)
 >Re: Sleeping in nanos (From: Ed Wynne <email@hidden>)
 >Re: Sleeping in nanos (From: Greg <email@hidden>)
 >Re: Sleeping in nanos (From: Jan Brittenson <email@hidden>)
 >Re: Sleeping in nanos (From: Ed Wynne <email@hidden>)
 >Re: Sleeping in nanos (From: Colin Hirsch <email@hidden>)

  • Prev by Date: Re: Sleeping in nanos
  • Next by Date: Re: Sleeping in nanos
  • Previous by thread: Re: Sleeping in nanos
  • Next by thread: Re: Sleeping in nanos
  • Index(es):
    • Date
    • Thread