[fpc-devel] Why FreeBSD sem_init() works different to Linux?

Henry Vermaak henry.vermaak at gmail.com
Thu Feb 7 15:54:32 CET 2013


On Thu, Feb 07, 2013 at 02:43:11PM +0000, Henry Vermaak wrote:
> On Thu, Feb 07, 2013 at 03:11:00PM +0100, Jonas Maebe wrote:
> > The interlocked* routines only guarantee that that particular value
> > is updated in atomic way across multiple cores. It does not
> > guarantee anything about memory access performed before or after
> > that interlocked* call. The memory barriers are to ensure that all
> > memory accesses before the lock-primitive (such as Enter/
> > LeaveCriticalSection) are also synchronized across all cores.
> 
> It may be a good idea for the documentation to explicitly say which
> functions do/do not imply memory barriers, since the linux kernel
> atomic_cmpxchg() and the Windows API guarantees full memory barriers, so
> people may expect that.

Most of the gcc __sync_* builtins guarantee a full barrier, too.

Henry



More information about the fpc-devel mailing list