MUTEX_ALLOC(D3)MUTEX_ALLOC(D3)NAME
MUTEX_ALLOC, MUTEX_INIT - mutual exclusion lock initialization
SYNOPSIS
#include <sys/types.h>
#include <sys/kmem.h>
#include <sys/ksynch.h>
#include <sys/ddi.h>
mutex_t *MUTEX_ALLOC(int type, int flag, char *name);
void MUTEX_INIT(mutex_t *mp, int type, char *name);
Arguments
type Type of mutual exclusion lock -- must be MUTEX_DEFAULT.
flag Specifies whether the caller is willing to sleep waiting for
memory.
name Name applied to the mutex -- only used when the metering locks
package is installed. Name may be a null pointer.
DESCRIPTION
MUTEX_ALLOC dynamically allocates and initializes an instance of a
sleeping mutual exclusion lock. MUTEX_INIT initializes an already-
allocated instance of a sleeping mutual exclusion lock. The mutex is
initialized to the unlocked state.
If flag is set to KM_SLEEP, the caller will sleep if necessary until
sufficient memory is available. If flag is set to KM_NOSLEEP, the caller
will not sleep, but MUTEX_ALLOC will return NULL if sufficient memory is
not immediately available.
Return Values
Upon successful completion, MUTEX_ALLOC returns a pointer to the newly
allocated lock. If KM_NOSLEEP is specified and sufficient memory is not
immediately available, MUTEX_ALLOC returns a NULL pointer.
USAGE
Level
Initialization or Base.
Synchronization Constraints
May sleep if flag is set to KM_SLEEP.
Driver-defined basic locks 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 and read/write locks may be held across calls
to this function regardless of the value of flag.
Page 1
MUTEX_ALLOC(D3)MUTEX_ALLOC(D3)REFERENCESMUTEX_DEALLOC(D3), MUTEX_DESTROY(D3), MUTEX_LOCK(D3), MUTEX_TRYLOCK(D3),
MUTEX_UNLOCK(D3), MUTEX_OWNED(D3), MUTEX_MINE(D3),
Page 2