Re: Sleeping in nanos
Re: Sleeping in nanos
- Subject: Re: Sleeping in nanos
- From: Michael Smith <email@hidden>
- Date: Wed, 7 Feb 2007 13:23:59 -0800
On Feb 6, 2007, at 8:49 AM, Greg wrote:
Thanks Terry for the info, I asked my question originally under the
(silly) assumption that nanosleep would sleep for the desired
amount after reading the man pages and checking the second argument
to it (a timespec called 'rmtp' in the manpage), which would
contain 0 (no difference) for its tv_nsec variable.
You should not check rmtp unless nanosleep returns -1 and errno is
EINTR. The manpage is quite specific about this.
I'm not a very big fan of this nanosleep function now, seeing how
on neither linux nor OS X can it ever sleep for less then 1000
nanoseconds, rendering the function seemingly useless.
The choice of nanoseconds permits an application to provide more
detail about its requirements. In the common case where code lives
well beyond the environment in which it was originally written this
information may allow a future runtime environment to do a better job.
There are plenty of situations where, even on modern hardware,
nanosleep might delay execution for less than 1µs.
It would have been nice had there been a more descriptive note
about this in the man pages of either system (beyond what's already
in there).
Manpages generally assume a level of basic understanding of systems
programming philosophy; attempting to explain these principles in
every manpage (would you want to see the same two or three hundred
pages appended to each one?) would be prohibitive.
A better request might be "where can I go to obtain this
understanding", and sadly there aren't many good answers beyond "you
just did".
= Mike
_______________________________________________
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