Content-type: text/html Manpage of RTAtomic

RTAtomic

Section: Chronolytix (3)
Updated: 2005-07-07
Index Return to Main Contents
 

NAME

RTAtomic - Chronolytix Lockless Atomic Operations Class  

SYNOPSYS

#include <RTAtomic.h>

unsigned RTAtomic_CompareAndSwap (volatile unsigned *value, unsigned old_value, unsigned new_value);

unsigned RTAtomic_Add_Return(int i, volatile unsigned int *p);

unsigned long RTAtomic_AtomicSwap(volatile unsigned long *p, unsigned long v);

void * RTAtomic_AtomicSwapPointer(volatile void *p, void *value);

 

DESCRIPTION

RTAtomic is the Chronolytix class for portably using specific intructions that modern CPUs have for manipulating registers and memory such that other CPUs and interrupts, etc. cannot interleave those accesses. This is valuable in so much as certain common operations wold require mutex protection (many instructions) whereas a RTAtomic operation, depending on CPU architecture, may be only one instruction.

RTAtomic_CompareAndSwap takes a new_value and if the value at *value is old_value, it will conditionally, atomically swap *value and new_value. The return value is true if the swap took place.

RTAtomic_Add_Return atomically increments the *p by i. The simple increment case can be constructed by making i=1.

RTAtomic_AtomicSwap and RTAtomic_AtomicSwapPointer unconditionally and atomically swap the content of pointer p and a value argument of an unsigned long or void pointer, respectively.

RTAtomic is a core Chronolytix function.  

MAGIC

None  

SEE ALSO

RTCommon RTRefCnt_Object


 

Index

NAME
SYNOPSYS
DESCRIPTION
MAGIC
SEE ALSO

This document was created by man2html, using the manual pages.
Time: 11:21:57 GMT, September 21, 2005