[ Previous | Next | Contents | Home | Search ]
AIX Version 4.3 Kernel and Subsystems Technical Reference, Volume 1

unlockl Kernel Service

Purpose

Unlocks a conventional process lock.

Syntax

#include <sys/types.h>
#include <sys/errno.h>
void unlockl (lock_word)
lock_t *lock_word;

Parameter

lock_word Specifies the address of the lock word.

Description

Note: The unlockl kernel service is provided for compatibility only and should not be used in new code, which should instead use simple locks or complex locks.

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.

Note: The unlockl kernel service can be called with interrupts disabled, only if the event or lock word is pinned.

Execution Environment

The unlockl kernel service can be called from the process environment only.

Return Values

The unlockl service has no return values.

Example

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);

Implementation Specifics

The unlockl kernel service is part of the Base Operating System (BOS) Runtime.

Related Information

The lockl kernel service.

Understanding Locking in AIX Kernel Extensions and Device Support Programming Concepts.

Locking Kernel Services in AIX Kernel Extensions and Device Support Programming Concepts

Preempting a System Call in AIX Kernel Extensions and Device Support Programming Concepts.

Interrupt Environment in AIX Kernel Extensions and Device Support Programming Concepts.


[ Previous | Next | Contents | Home | Search ]