Unlocks a conventional process lock.
#include <sys/types.h>
#include <sys/errno.h>
void unlockl ( lock_word)
lock_t *lock_word;
Item | Description |
---|---|
lock_word | Specifies the address of the lock word. |
The unlockl kernel service unlocks a conventional lock. Only the owner of a lock can unlock it. Once a lock is unlocked, the highest priority thread (if any) which is waiting for the lock is made runnable and may compete again for the lock. If there was at least one process waiting for the lock, the priority of the caller is recomputed. Preempting a System Call discusses how system calls can use locking kernel services when accessing global data.
The lockl and unlockl services do not maintain a nesting level count. A single call to the unlockl service unlocks the lock for the caller. The return code from the lockl service should be used to determine when to unlock the lock.
The unlockl kernel service can be called from the process environment only.
The unlockl service has no return values.
A call to the unlockl service can be coded as follows:
int lock_ret; /* return code from lockl() */
extern int lock_word; /* lock word that is external
and was initialized to
LOCK_AVAIL */
...
/* get lock prior to using resource */
lock_ret = lockl(lock_word, LOCK_SHORT)
/* use resource for which lock was obtained */
...
/* release lock if this was not a nested use */
if ( lock_ret != LOCK_NEST )
unlockl(lock_word);