STREAMS-UX Programmer's Guide (February 2007)

STREAMS Utilities Supported by HP-UX
Appendix B
184
NAME
LOCK_ALLOC () – Allocates spinlock structure.
SYNOPSIS
#include <sys/stream.h> #include <sys/semglobal.h>
lock_t *LOCK_ALLOC (uchar_t hierarchy, spl_t min_prilev, lkinfo_t *lkinfoptr, int flag);
PARAMETERS
hierarchy
Hierarchy determines the order in which this lock is to be acquired. The STREAMS/UX
LOCK_ALLOC() accepts the following hierarchy of parameter values. These are reserved for
STREAMS/UX modules and drivers.
STREAMS_USR1_LOCK_ORDER
STREAMS_USR2_LOCK_ORDER
STREAMS_USR3_LOCK_ORDER
min_prilev
This value is ignored in STREAMS/UX.
lkinfoptr
Pointer to the lkinfo structure. lk_name in the lkinfo structure (lkinfo_t) contains the
name of the lock.
flag
KM_SLEEP must be set.
DESCRIPTION
LOCK_ALLOC() is used to allocate and initialize a lock. It makes use of the native HP-UX alloc_spinlock()
primitive.
RETURN VALUES
LOCK_ALLOC() returns a pointer to the allocated lock on success. The calling thread will block, if the memory
is not available. If KM_SLEEP is not set, and memory is not available, LOCK_ALLOC() returns NULL.
CONSTRAINTS
LOCK_ALLOC() must be called from thread context. Spinlocks must not be held across the calls to
LOCK_ALLOC().