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

Technical Reference: Base Operating System and Extensions , Volume 2


_safe_fetch Subroutine

Purpose

Reads the value of a single word variable protected by a lock.

Library

Standard C library (libc.a)

Syntax

#include <sys/atomic_op.h>


int _safe_fetch ( word_addr)
atomic_p word_addr;

Parameter


word_addr Specifies the address of the single word variable.

Description

The _safe_fetch subroutine safely reads and returns a single word value that is protected by a lock. This subroutine is used to read protected data before releasing the lock word with the _clear_lock subroutine. If _safe_fetch is not used, instructions that access data just before a lock release could actually before performed after the lock release.

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

Return Values

This subroutine returns the value of the single word variable.

Implementation Specifics

The _safe_fetch subroutine is part of Base Operating System (BOS) Runtime.

Note that the _safe_fetch subroutine is intended for use only with the _check_lock and _clear_lock subroutines.

Related Information

The _check_lock subroutine, _clear_lock subroutine.


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