• 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: 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


  • Follow-Ups:
    • Re: Sleeping in nanos
      • From: Michael Smith <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: Terry Lambert <email@hidden>)
 >Re: Sleeping in nanos (From: Greg <email@hidden>)
 >Re: Sleeping in nanos (From: Terry Lambert <email@hidden>)
 >Re: Sleeping in nanos (From: Greg <email@hidden>)
 >Re: Sleeping in nanos (From: Michael Smith <email@hidden>)

  • Prev by Date: Re: kernel mprotecting my stack?
  • Next by Date: Re: Examining kernel thread state at run-time
  • Previous by thread: Re: Sleeping in nanos
  • Next by thread: Re: Sleeping in nanos
  • Index(es):
    • Date
    • Thread