summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_synch.c
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2007-02-23 16:22:09 +0000
committerjhb <jhb@FreeBSD.org>2007-02-23 16:22:09 +0000
commit401f7aaf8a4b36c5409b47caeb111224c19cfa64 (patch)
treec39c70c56ffcacc39b3ae90078a8abf26cbf23c3 /sys/kern/kern_synch.c
parent0e74f15f22d8628da5552eae28cccc969b056e13 (diff)
downloadFreeBSD-src-401f7aaf8a4b36c5409b47caeb111224c19cfa64.zip
FreeBSD-src-401f7aaf8a4b36c5409b47caeb111224c19cfa64.tar.gz
Add a new kernel sleep function pause(9). pause(9) is for places that
want an equivalent of DELAY(9) that sleeps instead of spins. It accepts a wmesg and a timeout and is not interrupted by signals. It uses a private wait channel that should never be woken up by wakeup(9) or wakeup_one(9). Glanced at by: phk
Diffstat (limited to 'sys/kern/kern_synch.c')
-rw-r--r--sys/kern/kern_synch.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c
index 6cc7c70..089919c 100644
--- a/sys/kern/kern_synch.c
+++ b/sys/kern/kern_synch.c
@@ -69,6 +69,7 @@ SYSINIT(synch_setup, SI_SUB_KICK_SCHEDULER, SI_ORDER_FIRST, synch_setup, NULL)
int hogticks;
int lbolt;
+static int pause_wchan;
static struct callout loadav_callout;
static struct callout lbolt_callout;
@@ -164,7 +165,10 @@ msleep(ident, mtx, priority, wmesg, timo)
if (TD_ON_SLEEPQ(td))
sleepq_remove(td, td->td_wchan);
- flags = SLEEPQ_MSLEEP;
+ if (ident == &pause_wchan)
+ flags = SLEEPQ_PAUSE;
+ else
+ flags = SLEEPQ_MSLEEP;
if (catch)
flags |= SLEEPQ_INTERRUPTIBLE;
@@ -308,6 +312,22 @@ msleep_spin(ident, mtx, wmesg, timo)
}
/*
+ * pause() is like tsleep() except that the intention is to not be
+ * explicitly woken up by another thread. Instead, the current thread
+ * simply wishes to sleep until the timeout expires. It is
+ * implemented using a dummy wait channel.
+ */
+int
+pause(wmesg, timo)
+ const char *wmesg;
+ int timo;
+{
+
+ KASSERT(timo != 0, ("pause: timeout required"));
+ return (tsleep(&pause_wchan, 0, wmesg, timo));
+}
+
+/*
* Make all threads sleeping on the specified identifier runnable.
*/
void
OpenPOWER on IntegriCloud