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

lock_read_to_write or lock_try_read_to_write Kernel Service

Purpose

Upgrades a complex lock from shared-read mode to exclusive-write mode.

Syntax

#include <sys/lock_def.h>
boolean_t lock_read_to_write (lock_addr)
complex_lock_t lock_addr;
boolean_t lock_try_read_to_write (lock_addr)
complex_lock_t lock_addr;

Parameter

lock_addr Specifies the address of the lock word to be converted from read-shared to write-exclusive mode.

Description

The lock_read_to_write and lock_try_read_to_write kernel services try to upgrade the specified complex lock from shared-read mode to exclusive-write mode. The lock is successfully upgraded if no other thread has already requested write-exclusive access for this lock. If the lock cannot be upgraded, it is no longer held on return from the lock_read_to_write kernel service; it is still held in shared-read mode on return from the lock_try_read_to_write kernel service.

The calling kernel thread must hold the lock in shared-read mode.

Execution Environment

The lock_read_to_write and lock_try_read_to_write kernel services can be called from the process environment only.

Return Values

The following only apply to lock_read_to_write:

TRUE Indicates that the lock was not upgraded and is no longer held.
FALSE Indicates that the lock was successfully upgraded to exclusive-write mode.

The following only apply to lock_try_read_to_write:

TRUE Indicates that the lock was successfully upgraded to exclusive-write mode.
FALSE Indicates that the lock was not upgraded and is held in read mode.

Implementation Specifics

The lock_read_to_write and lock_try_read_to_write kernel services are part of the Base Operating System (BOS) Runtime.

Related Information

The lock_init kernel service, lock_islocked kernel service, lock_done kernel service.

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


[ Previous | Next | Contents | Home | Search ]