sleep()

tom at rlgvax.UUCP tom at rlgvax.UUCP
Sat Jul 9 02:28:05 AEST 1983


The sleep() system call was changed to alarm(), pause() between V6 and PWB
UNIX.   At that time the whole sleep structure was redone.  The new setup
had the bug/limitation that there is a critical period between setting the
alarm and actually getting to sleep.  It also has the unfortunate point
of using and relying on signals, which generally suck.

However, before you jump to put in the old sleep() system call, you should be
aware of its problem, too.  The old way that sleep() was done had a very
inefficient implementation.  If several processes were sleeping, and the time
came for one to wake up, they ALL woke up.  They would ALL swap in (if they
were swapped out), check to see if their time elapsed, and if not, would
go back to sleep again.  In a system I designed once, I had the machine
thrashing like hell because several processes were supposedly sleeping!!!
Installing pause() speeded the machine up greatly.

So, if you are going to put sleep() back, make sure you do it well...

- Tom Beres
CCI, Reston (formerly RLG)
{sesimo, allegra, mcnc, brl-bmd}!rlgvax!tom



More information about the Comp.unix.wizards mailing list