summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_synch.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/kern/kern_synch.c')
-rw-r--r--sys/kern/kern_synch.c182
1 files changed, 1 insertions, 181 deletions
diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c
index 9c52802..ad86cdb 100644
--- a/sys/kern/kern_synch.c
+++ b/sys/kern/kern_synch.c
@@ -403,12 +403,6 @@ msleep(ident, mtx, priority, wmesg, timo)
KASSERT(p != NULL, ("msleep1"));
KASSERT(ident != NULL && p->p_stat == SRUN, ("msleep"));
- /*
- * Process may be sitting on a slpque if asleep() was called, remove
- * it before re-adding.
- */
- if (p->p_wchan != NULL)
- unsleep(p);
p->p_wchan = ident;
p->p_wmesg = wmesg;
@@ -487,181 +481,7 @@ msleep(ident, mtx, priority, wmesg, timo)
}
/*
- * asleep() - async sleep call. Place process on wait queue and return
- * immediately without blocking. The process stays runnable until await()
- * is called. If ident is NULL, remove process from wait queue if it is still
- * on one.
- *
- * Only the most recent sleep condition is effective when making successive
- * calls to asleep() or when calling msleep().
- *
- * The timeout, if any, is not initiated until await() is called. The sleep
- * priority, signal, and timeout is specified in the asleep() call but may be
- * overriden in the await() call.
- *
- * <<<<<<<< EXPERIMENTAL, UNTESTED >>>>>>>>>>
- */
-
-int
-asleep(void *ident, int priority, const char *wmesg, int timo)
-{
- struct proc *p = curproc;
-
- /*
- * Remove preexisting wait condition (if any) and place process
- * on appropriate slpque, but do not put process to sleep.
- */
-
- mtx_lock_spin(&sched_lock);
-
- if (p->p_wchan != NULL)
- unsleep(p);
-
- if (ident) {
- p->p_wchan = ident;
- p->p_wmesg = wmesg;
- p->p_slptime = 0;
- p->p_asleep.as_priority = priority;
- p->p_asleep.as_timo = timo;
- TAILQ_INSERT_TAIL(&slpque[LOOKUP(ident)], p, p_slpq);
- }
-
- mtx_unlock_spin(&sched_lock);
-
- return(0);
-}
-
-/*
- * await() - wait for async condition to occur. The process blocks until
- * wakeup() is called on the most recent asleep() address. If wakeup is called
- * prior to await(), await() winds up being a NOP.
- *
- * If await() is called more then once (without an intervening asleep() call),
- * await() is still effectively a NOP but it calls mi_switch() to give other
- * processes some cpu before returning. The process is left runnable.
- *
- * <<<<<<<< EXPERIMENTAL, UNTESTED >>>>>>>>>>
- */
-
-int
-await(int priority, int timo)
-{
- struct proc *p = curproc;
- int rval = 0;
-
- WITNESS_SLEEP(0, NULL);
- mtx_lock_spin(&sched_lock);
- if (cold || panicstr) {
- /*
- * After a panic, or during autoconfiguration,
- * just give interrupts a chance, then just return;
- * don't run any other procs or panic below,
- * in case this is the idle process and already asleep.
- */
- mtx_unlock_spin(&sched_lock);
- return (0);
- }
- DROP_GIANT_NOSWITCH();
-
- if (p->p_wchan != NULL) {
- int sig;
- int catch;
-
-#ifdef KTRACE
- if (p && KTRPOINT(p, KTR_CSW))
- ktrcsw(p->p_tracep, 1, 0);
-#endif
- /*
- * The call to await() can override defaults specified in
- * the original asleep().
- */
- if (priority < 0)
- priority = p->p_asleep.as_priority;
- if (timo < 0)
- timo = p->p_asleep.as_timo;
-
- /*
- * Install timeout
- */
-
- if (timo)
- callout_reset(&p->p_slpcallout, timo, endtsleep, p);
-
- sig = 0;
- catch = priority & PCATCH;
-
- if (catch) {
- p->p_sflag |= PS_SINTR;
- mtx_unlock_spin(&sched_lock);
- PROC_LOCK(p);
- sig = CURSIG(p);
- mtx_lock_spin(&sched_lock);
- PROC_UNLOCK_NOSWITCH(p);
- if (sig != 0) {
- if (p->p_wchan)
- unsleep(p);
- } else if (p->p_wchan == NULL)
- catch = 0;
- }
- if (p->p_wchan != NULL) {
- p->p_stat = SSLEEP;
- p->p_stats->p_ru.ru_nvcsw++;
- mi_switch();
- }
- KASSERT(p->p_stat == SRUN, ("running but not SRUN"));
- p->p_sflag &= ~PS_SINTR;
- if (p->p_sflag & PS_TIMEOUT) {
- p->p_sflag &= ~PS_TIMEOUT;
- if (sig == 0)
- rval = EWOULDBLOCK;
- } else if (timo)
- callout_stop(&p->p_slpcallout);
- mtx_unlock_spin(&sched_lock);
- if (rval == 0 && catch) {
- PROC_LOCK(p);
- if (sig != 0 || (sig = CURSIG(p))) {
- if (SIGISMEMBER(p->p_sigacts->ps_sigintr, sig))
- rval = EINTR;
- else
- rval = ERESTART;
- }
- PROC_UNLOCK(p);
- }
-#ifdef KTRACE
- mtx_lock(&Giant);
- if (KTRPOINT(p, KTR_CSW))
- ktrcsw(p->p_tracep, 0, 0);
- mtx_unlock(&Giant);
-#endif
- } else {
- /*
- * If as_priority is 0, await() has been called without an
- * intervening asleep(). We are still effectively a NOP,
- * but we call mi_switch() for safety.
- */
-
- if (p->p_asleep.as_priority == 0) {
- p->p_stats->p_ru.ru_nvcsw++;
- mi_switch();
- }
- mtx_unlock_spin(&sched_lock);
- }
-
- /*
- * clear p_asleep.as_priority as an indication that await() has been
- * called. If await() is called again without an intervening asleep(),
- * await() is still effectively a NOP but the above mi_switch() code
- * is triggered as a safety.
- */
- if (rval == 0)
- p->p_asleep.as_priority = 0;
-
- PICKUP_GIANT();
- return (rval);
-}
-
-/*
- * Implement timeout for msleep or asleep()/await()
+ * Implement timeout for msleep()
*
* If process hasn't been awakened (wchan non-zero),
* set timeout flag and undo the sleep. If proc
OpenPOWER on IntegriCloud