2 .\" Copyright (c) 1997, Sun Microsystems, Inc. All Rights Reserved
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH _LWP_MUTEX_LOCK 2 "Jul 30, 1992"
8 _lwp_mutex_lock, _lwp_mutex_unlock, _lwp_mutex_trylock \- mutual exclusion
14 \fBint\fR \fB_lwp_mutex_lock\fR(\fBlwp_mutex_t *\fR\fImp\fR);
19 \fBint\fR \fB_lwp_mutex_trylock\fR(\fBlwp_mutex_t *\fR\fImp\fR);
24 \fBint\fR \fB_lwp_mutex_unlock\fR(\fBlwp_mutex_t *\fR\fImp\fR);
30 These functions serialize the execution of lightweight processes. They are
31 useful for ensuring that only one lightweight process can execute a critical
32 section of code at any one time (mutual exclusion). LWP mutexes must be
33 initialized to 0 before use.
36 The \fB_lwp_mutex_lock()\fR function locks the LWP mutex pointed to by
37 \fImp\fR. If the mutex is already locked, the calling LWP blocks until the
38 mutex becomes available. When \fB_lwp_mutex_lock()\fR returns, the mutex is
39 locked and the calling LWP is the "owner".
42 The \fB_lwp_mutex_trylock()\fR function attempts to lock the mutex. If the
43 mutex is already locked it returns with an error. If the mutex is unlocked, it
44 is locked and \fB_lwp_mutex_trylock()\fR returns.
47 The \fB_lwp_mutex_unlock()\fR function unlocks a locked mutex. The mutex must
48 be locked and the calling LWP must be the one that last locked the mutex (the
49 owner). If any other LWPs are waiting for the mutex to become available, one of
54 Upon successful completion, \fB0\fR is returned. A non-zero value indicates an
59 If any of the following conditions are detected, \fB_lwp_mutex_lock()\fR,
60 \fB_lwp_mutex_trylock()\fR, and \fB_lwp_mutex_unlock()\fR fail and return the
68 The \fImp\fR argument points to an invalid LWP mutex.
77 The \fImp\fR argument points to an illegal address.
82 If any of the following conditions occur, \fB_lwp_mutex_trylock()\fR fails and
83 returns the corresponding value:
90 The \fImp\fR argument points to a locked mutex.
96 \fBIntro\fR(2), \fB_lwp_cond_wait\fR(2)