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

Item Description
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.