mirror of https://github.com/mkerrisk/man-pages
nanosleep.2: Describe "creeping sleep" problem
nanosleep() has a problem if used in a program that catches signals and those signals are delivered at a very high rate. Describe the problem, and note that clock_nanosleep(2) provides a solution. Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
This commit is contained in:
parent
91bf33ff1f
commit
1186d4c363
|
@ -194,6 +194,25 @@ or
|
||||||
This special extension was removed in kernel 2.5.39,
|
This special extension was removed in kernel 2.5.39,
|
||||||
and is thus not available in Linux 2.6.0 and later kernels.
|
and is thus not available in Linux 2.6.0 and later kernels.
|
||||||
.SH BUGS
|
.SH BUGS
|
||||||
|
If a program that catches signals and uses
|
||||||
|
.BR nanosleep ()
|
||||||
|
receives signals at a very high rate,
|
||||||
|
then scheduling delays and rounding errors in the kernel's
|
||||||
|
calculation of the sleep interval and the returned
|
||||||
|
.IR remain
|
||||||
|
value mean that the
|
||||||
|
.IR remain
|
||||||
|
value may steadily
|
||||||
|
.IR increase
|
||||||
|
on successive restarts of the
|
||||||
|
.BR nanosleep ()
|
||||||
|
call.
|
||||||
|
To avoid such problems, use
|
||||||
|
.BR clock_nanosleep (2)
|
||||||
|
with the
|
||||||
|
.BR TIMER_ABSTIME
|
||||||
|
flag to sleep to an absolute deadline.
|
||||||
|
|
||||||
In Linux 2.4, if
|
In Linux 2.4, if
|
||||||
.BR nanosleep ()
|
.BR nanosleep ()
|
||||||
is stopped by a signal (e.g.,
|
is stopped by a signal (e.g.,
|
||||||
|
|
Loading…
Reference in New Issue