Memory barrier, also known as membar or memory fence or fence instruction, is a type of barrier and a class of instruction which causes a central processing unit (CPU) or compiler to enforce an ordering constraint on memory operations issued before and after the barrier instruction.
CPUs employ performance optimizations that can result in out-of-order execution. The reordering of memory operations (loads and stores) normally goes unnoticed within a single thread of execution, but causes unpredictable behaviour in concurrent programs and device drivers unless carefully controlled. The exact nature of an ordering constraint is hardware dependent, and defined by the architecture's memory ordering model. Some architectures provide multiple barriers for enforcing different ordering constraints.
Memory barriers are typically used when implementing low-level machine code that operates on memory shared by multiple devices. Such code includes synchronization primitives and lock-free data structures on multiprocessor systems, and device drivers that communicate with computer hardware.
Read more about Memory Barrier: An Illustrative Example, Low-level Architecture-specific Primitives, Multithreaded Programming and Memory Visibility, Out-of-order Execution Versus Compiler Reordering Optimizations
Famous quotes containing the words memory and/or barrier:
“Near this spot are deposited the remains of one who possessed Beauty without Vanity, Strength without Insolence, Courage without Ferocity, and all the Virtues of Man without his Vices. This praise, which would be unmeaning Flattery, if inscribed over human ashes, is but a just Tribute to the Memory of BOATSWAIN, a Dog.”
—John Cam Hobhouse (17861869)
“Whatever may be our just grievances in the southern states, it is fitting that we acknowledge that, considering their poverty and past relationship to the Negro race, they have done remarkably well for the cause of education among us. That the whole South should commit itself to the principle that the colored people have a right to be educated is an immense acquisition to the cause of popular education.”
—Fannie Barrier Williams (18551944)