Top "Memory-barriers" questions

A memory barrier is a special processor instruction that imposes restrictions on the order in which memory accesses become visible to other processors/cores in a multi-processor or multi-core system.

difference in mfence and asm volatile ("" : : : "memory")

As far as I have understood, mfence is a hardware memory barrier while asm volatile ("" : : : "memory") is a compiler barrier. …

gcc x86 memory-barriers
How do I Understand Read Memory Barriers and Volatile

Some languages provide a volatile modifier that is described as performing a "read memory barrier" prior to reading the memory …

multithreading volatile memory-barriers
Why we need Thread.MemoryBarrier()?

In "C# 4 in a Nutshell", the author shows that this class can write 0 sometimes without MemoryBarrier, though I can't reproduce …

c# .net multithreading thread-safety memory-barriers
Does it make any sense to use the LFENCE instruction on x86/x86_64 processors?

Often in internet I find that LFENCE makes no sense in processors x86, ie it does nothing , so instead MFENCE …

assembly x86 x86-64 atomic memory-barriers
Understanding Linux Kernel Circular Buffer

There is an article at: http://lwn.net/Articles/378262/ that describes the Linux kernels circular buffer implementation. I have some …

linux concurrency circular-buffer memory-barriers
Fastest inline-assembly spinlock

I'm writing a multithreaded application in c++, where performance is critical. I need to use a lot of locking while …

c++ assembly x86 memory-barriers spinlock
Memory barriers in userspace? (Linux, x86-64)

It is easy to set memory barriers on the kernel side: the macros mb, wmb, rmb, etc. are always in …

c++ c multithreading lock-free memory-barriers
Atomic access to shared memory

I have a shared memory between multiple processes that interpets the memory in a certain way. Ex: DataBlock { int counter; …

c++ linux shared-memory memory-barriers stdatomic
Why do I need a memory barrier?

C# 4 in a Nutshell (highly recommended btw) uses the following code to demonstrate the concept of MemoryBarrier (assuming A and …

c# multithreading thread-safety shared-memory memory-barriers
C++ Memory Barriers for Atomics

I'm a newbie when it comes to this. Could anyone provide a simplified explanation of the differences between the following …

c++ windows visual-c++ memory-barriers