CVSROOT:        /cvs
Module name:    src
Changes by:     [email protected] 2021/01/07 08:24:52

Modified files:
        lib/libc/gen   : sleep.c 

Log message:
sleep(3): don't bypass nanosleep(2) if seconds is zero

sleep(3) does not call nanosleep(2) if seconds is zero.  This is bad.
As a simplified interface to nanosleep(2), sleep(3) should delegate
all decisions about whether or not to yield the CPU to nanosleep(2).

This patch removes the nanosleep(2) bypass from sleep(3).

This means that this code:

sleep(0);

will block for up to 1 tick, just like the equivalent nanosleep(2) call.

Neither FreeBSD nor NetBSD bypass nanosleep(2) in the zero case, so
this commit brings our sleep(3) closer to theirs in behavior.

As an added bonus, sleep(3) will now *always* appear in a ktrace(1) as
a call to nanosleep(2).

ok millert@

Reply via email to