diff options
Diffstat (limited to 'sys/kern/kern_synch.c')
-rw-r--r-- | sys/kern/kern_synch.c | 75 |
1 files changed, 38 insertions, 37 deletions
diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c index 9d887083455..16fc2d6f8ae 100644 --- a/sys/kern/kern_synch.c +++ b/sys/kern/kern_synch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_synch.c,v 1.62 2005/05/25 23:17:47 niklas Exp $ */ +/* $OpenBSD: kern_synch.c,v 1.63 2005/05/29 03:20:41 deraadt Exp $ */ /* $NetBSD: kern_synch.c,v 1.37 1996/04/22 01:38:37 christos Exp $ */ /*- @@ -145,12 +145,8 @@ ltsleep(ident, priority, wmesg, timo, interlock) else *qp->sq_tailp = p; *(qp->sq_tailp = &p->p_forw) = 0; - - p->p_stat = SSLEEP; - if (timo) timeout_add(&p->p_sleep_to, timo); - /* * We can now release the interlock; the scheduler_slock * is held, so a thread can't get in to do wakeup() before @@ -174,16 +170,13 @@ ltsleep(ident, priority, wmesg, timo, interlock) */ if (catch) { p->p_flag |= P_SINTR; - SCHED_UNLOCK(s); /* XXX - must unlock for CURSIG */ if ((sig = CURSIG(p)) != 0) { - SCHED_LOCK(s); if (p->p_wchan) unsleep(p); p->p_stat = SONPROC; SCHED_UNLOCK(s); goto resume; } - SCHED_LOCK(s); if (p->p_wchan == 0) { catch = 0; SCHED_UNLOCK(s); @@ -191,14 +184,22 @@ ltsleep(ident, priority, wmesg, timo, interlock) } } else sig = 0; + p->p_stat = SSLEEP; p->p_stats->p_ru.ru_nvcsw++; SCHED_ASSERT_LOCKED(); - mi_switch(s); + mi_switch(); #ifdef DDB /* handy breakpoint location after process "wakes" */ __asm(".globl bpendtsleep\nbpendtsleep:"); #endif + SCHED_ASSERT_UNLOCKED(); + /* + * Note! this splx belongs to the SCHED_LOCK(s) above, mi_switch + * releases the scheduler lock, but does not lower the spl. + */ + splx(s); + resume: #ifdef __HAVE_CPUINFO p->p_cpu->ci_schedstate.spc_curpriority = p->p_usrpri; @@ -269,13 +270,20 @@ endtsleep(arg) * Remove a process from its wait queue */ void -unsleep(struct proc *p) +unsleep(p) + register struct proc *p; { - struct slpque *qp; - struct proc **hp; - - SCHED_ASSERT_LOCKED(); + register struct slpque *qp; + register struct proc **hp; +#if 0 + int s; + /* + * XXX we cannot do recursive SCHED_LOCKing yet. All callers lock + * anyhow. + */ + SCHED_LOCK(s); +#endif if (p->p_wchan) { hp = &(qp = &slpque[LOOKUP(p->p_wchan)])->sq_head; while (*hp != p) @@ -285,39 +293,24 @@ unsleep(struct proc *p) qp->sq_tailp = hp; p->p_wchan = 0; } -} - -void -wakeup(void *ident) -{ - int s; - - SCHED_LOCK(s); - sched_wakeup(ident); - SCHED_UNLOCK(s); -} - -void -wakeup_n(void *ident, int n) -{ - int s; - - SCHED_LOCK(s); - sched_wakeup_n(ident, n); +#if 0 SCHED_UNLOCK(s); +#endif } /* * Make all processes sleeping on the specified identifier runnable. */ void -sched_wakeup_n(void *ident, int n) +wakeup_n(ident, n) + void *ident; + int n; { struct slpque *qp; struct proc *p, **q; + int s; - SCHED_ASSERT_LOCKED(); - + SCHED_LOCK(s); qp = &slpque[LOOKUP(ident)]; restart: for (q = &qp->sq_head; (p = *q) != NULL; ) { @@ -356,7 +349,7 @@ restart: need_resched(0); #endif } else { - sched_wakeup((caddr_t)&proc0); + wakeup((caddr_t)&proc0); } /* END INLINE EXPANSION */ @@ -368,4 +361,12 @@ restart: } else q = &p->p_forw; } + SCHED_UNLOCK(s); +} + +void +wakeup(chan) + void *chan; +{ + wakeup_n(chan, -1); } |