Standard C Library Functions membarops(3C)
NAME
membarops, membarenter, membarexit, membarproducer,
membarconsumer - memory access synchronization barrier
operations
SYNOPSIS
#include
void membarenter(void);
void membarexit(void);
void membarproducer(void);
void membarconsumer(void);
DESCRIPTION
The membarenter() function is a generic memory barrier used
during lock entry. It is placed after the memory operation
that acquires the lock to guarantee that the lock protects
its data. No stores from after the memory barrier will reach
visibility and no loads from after the barrier will be
resolved before the lock acquisition reaches global visibil-
ity.
The membarexit() function is a generic memory barrier used
during lock exit. It is placed before the memory opera-
tion that releases the lock to guarantee that the lock pro-
tects its data. All loads and stores issued before the bar-
rier will be resolved before the subsequent lock update
reaches visibility.
The membarenter() and membarexit() functions are used
together to allow regions of code to be in relaxed store
order and then ensure that the load or store order is main-
tained at a higher level. They are useful in the implementa-
tion of mutex exclusion locks.
The membarproducer() function arranges for all stores
issued before this point in the code to reach global visi-
bility before any stores that follow. This is useful in pro-
ducer modules that update a data item, then set a flag that
it is available. The memory barrier guarantees that the
available flag is not visible earlier than the updated data,
thereby imposing store ordering.
SunOS 5.11 Last change: 14 Feb 2005 1
Standard C Library Functions membarops(3C)
The membarconsumer() function arranges for all loads issued
before this point in the code to be completed before any
subsequent loads. This is useful in consumer modules that
check if data is available and read the data. The memory
barrier guarantees that the data is not sampled until after
the available flag has been seen, thereby imposing load ord-
ering.
RETURN VALUES
No values are returned.
ERORS
No errors are defined.
ATRIBUTES
See attributes(5) for descriptions of the following attri-
butes:
ATRIBUTE TYPE ATRIBUTE VALUE
Interface Stability Stable
MT-Level MT-Safe
SEE ALSO
atomicadd(3C), atomicand(3C), atomicbits(3C),
atomiccas(3C), atomicdec(3C), atomicinc(3C),
atomicops(3C), atomicor(3C), atomicswap(3C), attri-
butes(5), atomicops(9F)
NOTES
Atomic instructions (see atomicops(3C)) ensure global visi-
bility of atomically-modified variables on completion. In a
relaxed store order system, this does not guarantee that the
visibility of other variables will be synchronized with the
completion of the atomic instruction. If such synchroniza-
tion is required, memory barrier instructions must be used.
SunOS 5.11 Last change: 14 Feb 2005 2
|