_spin_init(3synch) _spin_init(3synch)
NAME
_spin_init - initialize a spin lock
SYNOPSIS
cc [options] -Kthread file
#include <synch.h>
int _spin_init(spin_t *lock, void *arg);
Parameters
lock pointer to spin lock to be initialized
arg NULL (reserved for future use)
DESCRIPTION
_spin_init initializes the spin lock pointed to by lock to the
unlocked state. Once initialized, the spin lock can be used
any number of times without being re-initialized.
lock Parameter
lock points to the spin lock to be initialized.
arg Parameter
arg should be set to NULL. It is not currently used, but is
reserved for future use.
Static Spin Lock Initialization
In this implementation, a spin lock can be initialized
statically if its storage is zero-filled. In this case, the
spin lock is of type USYNC_THREAD, and _spin_init need not be
called.
Return Values
_spin_init returns zero for success and an error number for
failure, as described below.
Errors
If one of the following conditions is detected, _spin_init
returns the corresponding value:
EINVAL Invalid argument specified.
USAGE
Warnings
Spin locks should not be used on a uniprocessor. In the best
case, a spin lock on a uniprocessor will waste resources,
slowing down the owner of the lock; in the worst case, it will
Copyright 1994 Novell, Inc. Page 1
_spin_init(3synch) _spin_init(3synch)
deadlock the processor.
_spin_init does not examine the lock argument before
initializing it. If _spin_init is called more than once for
the same spin lock, it will overwrite its state. It is the
user's responsibility to ensure that _spin_init is only called
once for each spin lock.
Operations on locks initialized with _spin_init are not
recursive-a thread can deadlock if it attempts to relock a
spin lock that it already has locked.
REFERENCES
_spin(3synch), _spin_destroy(3synch), _spin_lock(3synch),
_spin_trylock(3synch), _spin_unlock(3synch), synch(3synch)
Copyright 1994 Novell, Inc. Page 2