Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Memory barrier
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Computer synchronizing instruction}} {{More citations needed|date=January 2016}} {{Use American English|date=January 2025}} {{Use mdy dates|date=January 2025}} In [[computing]], a '''memory barrier''', also known as a '''membar''', '''memory fence''' or '''fence instruction''', is a type of [[Barrier (computer science)|barrier]] [[Instruction (computer science)|instruction]] that causes a [[central processing unit]] (CPU) or [[compiler]] to enforce an [[Memory ordering|ordering]] constraint on [[Random-access memory|memory]] operations issued before and after the barrier instruction. This typically means that operations issued prior to the barrier are guaranteed to be performed before operations issued after the barrier. Memory barriers are necessary because most modern CPUs employ performance optimizations that can result in [[out-of-order execution]]. This reordering of memory operations (loads and stores) normally goes unnoticed within a single [[Thread (computing)|thread of execution]], but can cause unpredictable behavior in [[Concurrent computing|concurrent programs]] and [[device driver]]s unless carefully controlled. The exact nature of an ordering constraint is hardware dependent and defined by the architecture's [[memory model (programming)|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 (computer science)|synchronization]] [[Language primitive|primitives]] and [[Non-blocking synchronization|lock-free]] data structures on [[Multiprocessing|multiprocessor]] systems, and device drivers that communicate with [[computer hardware]].
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)