Reordering Summary
The Xbox 360 CPU reorders memory operations much more aggressively than do x86 and x64 CPUs, as shown in the following table. For more details, consult the processor documentation.
Reordering Activity | x86 and x64 | Xbox 360 |
---|---|---|
Reads moving ahead of reads | No | Yes |
Writes moving ahead of writes | No | Yes |
Writes moving ahead of reads | No | Yes |
Reads moving ahead of writes | Yes | Yes |
Read-Acquire and Write-Release Barriers
The main constructs used to prevent reordering of reads and writes are called read-acquire and write-release barriers. A read-acquire is a read of a flag or other variable to gain ownership of a resource, coupled with a barrier against reordering. Similarly, a write-release is a write of a flag or other variable to give away ownership of a resource, coupled with a barrier against reordering.
The formal definitions, courtesy of Herb Sutter, are:
- A read-acquire executes before all reads and writes by the same thread that follow it in program order.
- A write-release executes after all reads and writes by the same thread that precede it in program order.