[ Previous | Next | Contents | Glossary | Home | Search ]
AIX Version 4.3 Base Operating System and Extensions Technical Reference, Volume 1

_check_lock Subroutine

Purpose

Conditionally updates a single word variable atomically.

Library

Standard C library (libc.a)

Syntax

#include <sys/atomic_op.h>
boolean_t _check_lock (word_addr, old_val, new_val)
atomic_p word_addr;
int old_val;
int new_val;

Parameters

word_addr Specifies the address of the single word variable.
old_val Specifies the old value to be checked against the value of the single word variable.
new_val Specifies the new value to be conditionally assigned to the single word variable.

Description

The _check_lock subroutine performs an atomic (uninterruptible) sequence of operations. The compare_and_swap subroutine is similar, but does not issue synchronization instructions and therefore is inappropriate for updating lock words.

Note: The word variable must be aligned on a full word boundary.

Return Values

FALSE Indicates that the single word variable was equal to the old value and has been set to the new value.
TRUE Indicates that the single word variable was not equal to the old value and has been left unchanged.

Related Information

The _clear_lock subroutine, _safe_fetch subroutine.


[ Previous | Next | Contents | Glossary | Home | Search ]