Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] using rusage



On 2008-06-20 08:38 +0900 (Fri), Josh Glover wrote:

> 2. Use nanosleep(2) instead of sleep(2). nanosleep(2) correctly
> handles signals, and will get you closer to 1.0 seconds than sleep(2)
> will.

What's the difference in the signal handling? From the BSD manpages, it
looks as if both treat signals in the same way.

And why do you think nanosleep will get you closer than sleep? Neither
guarantees any more than you'll sleep at least as long as requested. Note
that this:

> Therefore, nanosleep() pauses always for at least the specified time,
> however it can take up to 10 ms longer than specified until the
> process becomes runnable again.

does not actually mean that, once you're runnable, you'll actually run.
On a very busy system, it could easily be hundreds of ms., or even even
thousands, if you're swapped out, after that time that you actually run
again.

cjs
-- 
Curt Sampson       <cjs@example.com>        +81 90 7737 2974   
Mobile sites and software consulting: http://www.starling-software.com


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links