Re: Sleeping in nanos
Re: Sleeping in nanos
- Subject: Re: Sleeping in nanos
- From: Greg <email@hidden>
- Date: Wed, 7 Feb 2007 18:07:53 -0500
On Feb 7, 2007, at 4:23 PM, Michael Smith wrote:
You should not check rmtp unless nanosleep returns -1 and errno is
EINTR. The manpage is quite specific about this.
The man page does not say it in those terms, it implies that by
sticking two sentences next to each other, it could definitely have
been more explicit.
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.
Now that is bad programming philosophy. When a developer calls a
function that claims it will sleep in nanoseconds, the programmer
expects it to do just that unless it says otherwise. When the
function does not return in error and set the rmtp variable
accordingly, this only serves to further confuse the developer.
In time-critical applications, which is most likely the case when
using a function like nanosleep, the developer expects predictable
behavior that is well documented. When his application must run on
multiple systems, it does not help that the function behaves
completely different and does not provide an adequate explanation for
the discrepancy.
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.
You are correct when you say that man pages are not designed to teach
programming philosophy, they are designed to document the behavior
some some particular function or command. The man page on nanosleep
does not do that. I'm not asking for "hundreds of pages", a sentence
or two would have sufficed for this.
- Greg _______________________________________________
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