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

fetch_and_and or fetch_and_or Kernel Service

Purpose

Clears and sets bits in a single word variable atomically.

Syntax

#include <sys/atomic_op.h>

uint fetch_and_and ( word_addr, mask)
atomic_p word_addr;
int mask;

uint fetch_and_or ( word_addr, mask)
atomic_p word_addr;
int mask;

Parameters

word_addr Specifies the address of the single word variable whose bits are to be cleared or set.
mask Specifies the bit mask which is to be applied to the single word variable.

Description

The fetch_and_and and fetch_and_or kernel services respectively clear and set bits in one word, according to a bit mask, as a single atomic operation. The fetch_and_and service clears bits in the word which correspond to clear bits in the bit mask, and the fetch_and_or service sets bits in the word which correspond to set bits in the bit mask.

These operations are useful when a variable containing bit flags is shared between several kernel threads, since they ensure that the fetch, update, and store operations used to clear or set a bit in the variable occur atomically (are not interruptible).

Note: The word containing the bit flags must be aligned on a full word boundary.

Execution Environment

The fetch_and_and and fetch_and_or kernel services can be called from either the process or interrupt environment.

Return Values

The fetch_and_and and fetch_and_or kernel services return the original value of the word.

Implementation Specifics

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

Related Information

The fetch_and_add kernel service, compare_and_swap kernel service.

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


[ Previous | Next | Contents | Home | Search ]