SV_ALLOC(D3)SV_ALLOC(D3)NAME
SV_ALLOC, SV_INIT - synchronization variable initialization
SYNOPSIS
#include <sys/types.h>
#include <sys/kmem.h>
#include <sys/ksynch.h>
#include <sys/ddi.h>
#include <sys/sema.h>
sv_t *SV_ALLOC(int type, int flag, char *name);
void SV_INIT(sv_t *svp, int type, char *name);
Arguments
svp Pointer to uninitialized synchronization variable.
type Specifies the order in which threads of execution that are
waiting on the synchronization variable are dequeued when
SV_SIGNAL or SV_BROADCAST are called.
flag Specifies whether the caller is willing to sleep waiting for
memory.
name Ascii string associated with the synchronization object.
DESCRIPTIONSV_ALLOC dynamically allocates and initializes an instance of a
synchronization variable. SV_INIT initializes an instance of a
synchronization variable.
If type is set to either SV_DEFAULT or SV_FIFO, waiting threads of
execution are wakened in first-in, first-out order; if the type is
SV_LIFO, they are dequeued in first-in, last-out order. If the
synchronization variable is of type SV_PRIO, waiters will be processed in
priority order.
If flag is set to KM_SLEEP, the caller of SV_ALLOC will sleep if
necessary until sufficient memory is available. If flag is set to
KM_NOSLEEP, the caller will not sleep, but SV_ALLOC will return NULL if
sufficient memory is not immediately available.
The name argument is only used if the metering sleep-locks package is
installed. A null name is ignored.
Return Values
Upon successful completion, SV_ALLOC returns a pointer to the newly
allocated lock. If KM_NOSLEEP is specified and sufficient memory is not
immediately available, SV_ALLOC returns a NULL pointer.
Page 1
SV_ALLOC(D3)SV_ALLOC(D3)USAGE
Level
Base or Initialization.
Synchronization Constraints
SV_ALLOC may sleep if flag is set to KM_SLEEP.
Driver-defined basic locks and read/write locks may be held across calls
to this function if flag is KM_NOSLEEP but may not be held if flag is
KM_SLEEP.
Driver-defined sleep locks may be held across calls to this function
regardless of the value of flag.
REFERENCESSV_DEALLOC(D3), SV_DESTROY(D3), SV_WAIT(D3), SV_WAIT_SIG(D3),
SV_SIGNAL(D3), SV_BROADCAST(D3).
Page 2