diff options
author | jake <jake@FreeBSD.org> | 2001-07-04 00:32:50 +0000 |
---|---|---|
committer | jake <jake@FreeBSD.org> | 2001-07-04 00:32:50 +0000 |
commit | 33e85623fa7950794d670bf31ce9bde30f6422b5 (patch) | |
tree | 610b771ef4c4637047495d810aa389e4f971c14d /sys/kern/kern_synch.c | |
parent | 0deba2c342284728c367d996a120510bed8a07a4 (diff) | |
download | FreeBSD-src-33e85623fa7950794d670bf31ce9bde30f6422b5.zip FreeBSD-src-33e85623fa7950794d670bf31ce9bde30f6422b5.tar.gz |
Implement mwakeup, mwakeup_one, cv_signal_drop and cv_broadcast_drop.
These take an additional mutex argument, which is dropped before any
processes are made runnable. This can avoid contention on the mutex
if the processes would immediately acquire it, and is done in such a
way that wakeups will not be lost.
Reviewed by: jhb
Diffstat (limited to 'sys/kern/kern_synch.c')
-rw-r--r-- | sys/kern/kern_synch.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c index 530b67e..7d55f67 100644 --- a/sys/kern/kern_synch.c +++ b/sys/kern/kern_synch.c @@ -709,16 +709,21 @@ unsleep(p) } /* - * Make all processes sleeping on the specified identifier runnable. + * Make all processes sleeping on the specified identifier runnable. If + * non-NULL, the specified mutex is dropped before any processes are made + * runnable. */ void -wakeup(ident) +mwakeup(ident, mtx) register void *ident; + register struct mtx *mtx; { register struct slpquehead *qp; register struct proc *p; mtx_lock_spin(&sched_lock); + if (mtx != NULL) + mtx_unlock_flags(mtx, MTX_NOSWITCH); qp = &slpque[LOOKUP(ident)]; restart: TAILQ_FOREACH(p, qp, p_slpq) { @@ -751,16 +756,20 @@ restart: /* * Make a process sleeping on the specified identifier runnable. * May wake more than one process if a target process is currently - * swapped out. + * swapped out. If non-NULL, the specified mutex is dropped before + * a process is made runnable. */ void -wakeup_one(ident) +mwakeup_one(ident, mtx) register void *ident; + register struct mtx *mtx; { register struct slpquehead *qp; register struct proc *p; mtx_lock_spin(&sched_lock); + if (mtx != NULL) + mtx_unlock_flags(mtx, MTX_NOSWITCH); qp = &slpque[LOOKUP(ident)]; TAILQ_FOREACH(p, qp, p_slpq) { |