.Dd May 26, 2004 .Dt BARRIER 3 .Os Darwin .Sh NAME .Nm OSMemoryBarrier .Nd memory barrier to order loads and stores .Sh LIBRARY .Lb libc .Sh SYNOPSIS .In libkern/OSAtomic.h .Ft void .Fn OSMemoryBarrier "void" .Sh DESCRIPTION .Fn OSMemoryBarrier strictly orders memory accesses in a weakly ordered memory model such as with PowerPC, by creating a barrier. All loads and stores executed in sequential program order before the barrier will complete with respect to the memory coherence mechanism, before any load or store executed after the barrier. Used with an atomic operation, the barrier can be used to create custom synchronization protocols as an alternative to the spinlock or queue/dequeue operations. Note that this barrier does not order uncached loads and stores. On a uniprocessor, the barrier operation is typically optimized into a nop. .Sh SEE ALSO .Xr atomic 3 , .Xr spinlock 3