summaryrefslogtreecommitdiffstats
path: root/sys/sys
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 /sys/sys
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 'sys/sys')
-rw-r--r--sys/sys/proc.h2
-rw-r--r--sys/sys/sleepqueue.h3
-rw-r--r--sys/sys/time.h2
3 files changed, 7 insertions, 0 deletions
diff --git a/sys/sys/proc.h b/sys/sys/proc.h
index 140732f..178b980 100644
--- a/sys/sys/proc.h
+++ b/sys/sys/proc.h
@@ -148,6 +148,7 @@ struct pargs {
* o - ktrace lock
* q - td_contested lock
* r - p_peers lock
+ * s - see sleepq_switch(), sleeping_on_old_rtc(), and sleep(9)
* t - thread lock
* u - process stat lock
* w - process timer lock
@@ -282,6 +283,7 @@ struct thread {
int td_no_sleeping; /* (k) Sleeping disabled count. */
int td_dom_rr_idx; /* (k) RR Numa domain selection. */
void *td_su; /* (k) FFS SU private */
+ int td_rtcgen; /* (s) rtc_generation of abs. sleep */
#define td_endzero td_sigmask
/* Copied during fork1() or create_thread(). */
diff --git a/sys/sys/sleepqueue.h b/sys/sys/sleepqueue.h
index d59dc7e..30a1893 100644
--- a/sys/sys/sleepqueue.h
+++ b/sys/sys/sleepqueue.h
@@ -90,11 +90,14 @@ void sleepq_add(void *wchan, struct lock_object *lock, const char *wmesg,
int flags, int queue);
struct sleepqueue *sleepq_alloc(void);
int sleepq_broadcast(void *wchan, int flags, int pri, int queue);
+void sleepq_chains_remove_matching(bool (*matches)(struct thread *));
void sleepq_free(struct sleepqueue *sq);
void sleepq_lock(void *wchan);
struct sleepqueue *sleepq_lookup(void *wchan);
void sleepq_release(void *wchan);
void sleepq_remove(struct thread *td, void *wchan);
+int sleepq_remove_matching(struct sleepqueue *sq, int queue,
+ bool (*matches)(struct thread *), int pri);
int sleepq_signal(void *wchan, int flags, int pri, int queue);
void sleepq_set_timeout_sbt(void *wchan, sbintime_t sbt,
sbintime_t pr, int flags);
diff --git a/sys/sys/time.h b/sys/sys/time.h
index 659f8e0..f2a6301 100644
--- a/sys/sys/time.h
+++ b/sys/sys/time.h
@@ -383,6 +383,8 @@ extern struct bintime bt_tickthreshold;
extern sbintime_t sbt_timethreshold;
extern sbintime_t sbt_tickthreshold;
+extern volatile int rtc_generation;
+
/*
* Functions for looking at our clock: [get]{bin,nano,micro}[up]time()
*
OpenPOWER on IntegriCloud