Re: Sleeping in nanos
Re: Sleeping in nanos
- Subject: Re: Sleeping in nanos
- From: Graham J Lee <email@hidden>
- Date: Thu, 8 Feb 2007 17:17:33 +0000
On 8 Feb 2007, at 17:11, Greg wrote:
On Feb 8, 2007, at 12:03 PM, Graham J Lee wrote:
I think there's a missed point here; even if the above were false
you still wouldn't get the results I think you expect to get.
Even if nanosleep() did truly sleep your thread for exactly one
nanosecond, the time elapsed between the start of the sleep and
the scheduler running your thread again is down to the scheduler,
has nothing to do with your thread, and is pretty much guaranteed
to be equal to or (more likely) greater than the sleep time
requested.
[...]
Thanks for pointing that out. One has to wonder then, why provide
such a function to developers and claim that it *can* possibly
sleep for the amount of time requested?
Because it might. Just not on a Mac sold so far :-)
Like I said before, this function is mainly useful in *time-
critical applications*, and in such applications, this
unpredictable function is absolutely useless.
BTW, there is a POSIX function for determining the resolution of the
clock, which you could use to see whether nanosecond-level precision
is at all on the cards. That's the good news. The bad news is that
it's part of the _POSIX_TIMERS option, which Tiger doesn't implement
(and I have no idea about Leotard). Time to get back over to
bugreport.apple.com ;-)
Cheers,
Graham.
_______________________________________________
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