- Require that cv_signal/cv_broadcast be called with the interlock held.

- Provide 'async' versions that don't need the interlock.
This commit is contained in:
ad 2007-02-03 16:39:53 +00:00
parent 3f280a11a4
commit 00b8f6d201
1 changed files with 27 additions and 3 deletions

View File

@ -1,4 +1,4 @@
.\" $NetBSD: condvar.9,v 1.5 2007/02/02 07:36:09 wiz Exp $
.\" $NetBSD: condvar.9,v 1.6 2007/02/03 16:39:53 ad Exp $
.\"
.\" Copyright (c) 2006, 2007 The NetBSD Foundation, Inc.
.\" All rights reserved.
@ -34,7 +34,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd February 2, 2007
.Dd February 3, 2007
.Dt CONDVAR 9
.Os
.Sh NAME
@ -47,7 +47,9 @@
.Nm cv_timedwait ,
.Nm cv_timedwait_sig ,
.Nm cv_signal ,
.Nm cv_broadcast
.Nm cv_broadcast ,
.Nm cv_signal_async ,
.Nm cv_broadcast_async
.Nd condition variables
.Sh SYNOPSIS
.In sys/condvar.h
@ -67,6 +69,10 @@
.Fn cv_signal "kcondvar_t *cv"
.Ft void
.Fn cv_broadcast "kcondvar_t *cv"
.Ft void
.Fn cv_signal_async "kcondvar_t *cv"
.Ft void
.Fn cv_broadcast_async "kcondvar_t *cv"
.Sh DESCRIPTION
Condition variables (CVs) are used in the kernel to synchronize access
to resources that are limited (for example, memory) and to wait for
@ -177,6 +183,10 @@ if the timeout expires.
.Pp
Awaken one LWP (potentially among many) that is waiting on the specified
condition variable.
The mutex passed to the wait function
.Po Fa mtx Pc
must also be held when calling
.Fn cv_signal .
.Pp
(Note that
.Fn cv_signal
@ -185,6 +195,20 @@ sense to LWPs waiting on a CV.)
.It Fn cv_broadcast "cv"
.Pp
Awaken all LWPs waiting on the specified condition variable.
The mutex passed to the wait function
.Po Fa mtx Pc
must also be held when calling
.Fn cv_broadcast .
.It Fn cv_signal_async "cv" , Fn cv_broadcast_async "cv"
.Pp
As per
.Fn cv_signal
and
.Fn cv_broadcast ,
but the interlock
.Po Fa mtx Pc
need not be held.
Use of these methods is discouraged as they are more costly to execute.
.El
.Sh EXAMPLES
.Bd -literal