Prevent certain kinds of compiler or processor optimizations that can reorder memory operations

Types

  • Load Barriers (Read Barriers): Ensure that all load operations specified before the barrier are completed before any subsequent load operations.
  • Store Barriers (Write Barriers): Ensure that all store operations specified before the barrier are completed before any subsequent store operations.
  • Full Barriers (Read-Write Barriers): Combine the effects of both load and store barriers, ensuring that all load and store operations specified before the barrier are completed before any subsequent load or store operations. This is the most restrictive type of barrier.