summaryrefslogtreecommitdiffstats
path: root/share/man/man9/sleep.9
diff options
context:
space:
mode:
authorvangyzen <vangyzen@FreeBSD.org>2017-03-29 01:21:48 +0000
committervangyzen <vangyzen@FreeBSD.org>2017-03-29 01:21:48 +0000
commitbd46ba6d54fe8f44fe1bb52e9a06fe4bb3d369e9 (patch)
tree49fcd51eeaee8320f9ba3df2b05faff3b9c6caef /share/man/man9/sleep.9
parent58daaa12cbecdaecc5fa5af9393cb7074e3cc80a (diff)
downloadFreeBSD-src-bd46ba6d54fe8f44fe1bb52e9a06fe4bb3d369e9.zip
FreeBSD-src-bd46ba6d54fe8f44fe1bb52e9a06fe4bb3d369e9.tar.gz
MFC r315280 r315287
When the RTC is adjusted, reevaluate absolute sleep times based on the RTC POSIX 2008 says this about clock_settime(2): If the value of the CLOCK_REALTIME clock is set via clock_settime(), the new value of the clock shall be used to determine the time of expiration for absolute time services based upon the CLOCK_REALTIME clock. This applies to the time at which armed absolute timers expire. If the absolute time requested at the invocation of such a time service is before the new value of the clock, the time service shall expire immediately as if the clock had reached the requested time normally. Setting the value of the CLOCK_REALTIME clock via clock_settime() shall have no effect on threads that are blocked waiting for a relative time service based upon this clock, including the nanosleep() function; nor on the expiration of relative timers based upon this clock. Consequently, these time services shall expire when the requested relative interval elapses, independently of the new or old value of the clock. When the real-time clock is adjusted, such as by clock_settime(3), wake any threads sleeping until an absolute real-clock time. Such a sleep is indicated by a non-zero td_rtcgen. The sleep functions will set that field to zero and return zero to tell the caller to reevaluate its sleep duration based on the new value of the clock. At present, this affects the following functions: pthread_cond_timedwait(3) pthread_mutex_timedlock(3) pthread_rwlock_timedrdlock(3) pthread_rwlock_timedwrlock(3) sem_timedwait(3) sem_clockwait_np(3) I'm working on adding clock_nanosleep(2), which will also be affected. Reported by: Sebastian Huber <sebastian.huber@embedded-brains.de> Relnotes: yes Sponsored by: Dell EMC
Diffstat (limited to 'share/man/man9/sleep.9')
-rw-r--r--share/man/man9/sleep.918
1 files changed, 18 insertions, 0 deletions
diff --git a/share/man/man9/sleep.9 b/share/man/man9/sleep.9
index 469d09f..9a72123 100644
--- a/share/man/man9/sleep.9
+++ b/share/man/man9/sleep.9
@@ -280,6 +280,21 @@ to
pay particular attention to ensure that no other threads wait on the
same
.Fa chan .
+.Pp
+If the timeout given by
+.Fa timo
+or
+.Fa sbt
+is based on an absolute real-time clock value,
+then the thread should copy the global
+.Va rtc_generation
+into its
+.Va td_rtcgen
+member before reading the RTC.
+If the real-time clock is adjusted, these functions will set
+.Va td_rtcgen
+to zero and return zero.
+The caller should reconsider its orientation with the new RTC value.
.Sh RETURN VALUES
When awakened by a call to
.Fn wakeup
@@ -298,6 +313,9 @@ the
.Fn msleep_spin ,
.Fn tsleep ,
and locking primitive sleep functions return 0.
+Zero can also be returned when the real-time clock is adjusted;
+see above regarding
+.Va td_rtcgen .
Otherwise, a non-zero error code is returned.
.Sh ERRORS
.Fn msleep ,
OpenPOWER on IntegriCloud