[ Bottom of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]

Technical Reference: Base Operating System and Extensions, Volume 2

test_and_set Subroutine

Purpose

Atomically tests and sets a memory location.

Library

Standard C library (libc.a)

Syntax

#include <sys/atomic_op.h>

boolean_t test_and_set (word_addr, mask)
atomic_p word_addr;
int mask;

Description

The test_and_set subroutine attempts to atomically OR the value stored at word_addr with the value specified by mask. If any bit in mask was already set in the value stored at word_addr, no update is made.

Parameters

word_addr Specifies the address of the memory location to be set.
mask Specifies the mask value to be used to set the memory location specified by word_addr.

Return Values

The test_and_set subroutine returns true if the the value stored at word_addr was updated. Otherwise, it returns false.

Related Information

The fetch_and_and or fetch_and_or Subroutine in AIX 5L Version 5.2 Technical Reference: Base Operating System and Extensions Volume 1.

[ Top of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]