1
0
Files
irix-657m-src/eoe/man/manD/LOCK.d3
2022-09-29 17:59:04 +03:00

67 lines
2.2 KiB
Plaintext

.\" Copyright 1991, 1992 UNIX System Laboratories, Inc.
.TH LOCK D3
.SH NAME
LOCK \- acquire a basic lock
.SH SYNOPSIS
.nf
.ft 3
#include <sys/types.h>
#include <sys/ksynch.h>
#include <sys/ddi.h>
.sp .8v
int LOCK(lock_t *\f2lockp\fP, pl_t \f2pl\fP);
.ft 1
.fi
.SS Arguments
.RS 0
.IP "\f2lockp\f1" 10n
Pointer to the basic lock to be acquired.
.IP "\f2pl\f1" 10n
The interrupt priority level to be set while the lock is held
by the caller.
.RE
.SH DESCRIPTION
LOCK sets the interrupt priority level in accordance with the value
specified by \f2pl\f1 and acquires the lock specified by \f2lockp\f1.
If the lock is not immediately available, the caller will busy-wait
until the lock is available.
.SS "Return Values"
Upon acquiring the lock, LOCK returns the previous mask for
use by UNLOCK.
Your driver should treat this return
integer as an "opaque" value and should not try to compare it with any
other value or perform any operation on it.
.SH USAGE
Because some implementations require that interrupts that might attempt
to acquire the lock be blocked on the processor on which the lock is
held, portable drivers must specify a \f2pl\f1 value that is sufficient
to block out any interrupt handler that might attempt to acquire this lock.
See the description of the \f2min_pl\f1 argument to \f4LOCK_ALLOC\f1(D3)
for additional discussion and a list of the valid values for \f2pl\f1.
.SS Level
Base or Interrupt.
.SS "Synchronization Constraints"
Driver-defined sleep locks may be held across calls to this function.
.P
Driver-defined basic locks and read/write locks may be held
across calls to this function subject to the hierarchy -- but basic locks
must be unlocked in the reverse order in which they were acquired
(first-in, last-out).
.SS Warnings
Basic locks are not recursive.
A call to LOCK attempting to acquire a lock that is currently held
by the calling context will result in deadlock.
.P
Calls to LOCK should honor the hierarchy ordering to avoid deadlock.
.P
When called from interrupt level,
the \f2pl\f1 argument must not specify a priority level below the level at
which the interrupt handler is running.
.SH REFERENCES
LOCK_ALLOC(D3),
LOCK_DEALLOC(D3),
LOCK_DESTROY(D3),
LOCK_INIT(D3),
TRYLOCK(D3),
UNLOCK(D3).