ARMv8
synchronization model.
ARMv8 designs a synchronization model to provide non-blocking synchronization. This model includes the following key elements:
ARMv8 defines two states for memory blocks accessed by PE:
When a memory block is marked as Exclusive Access for a PE, this means that this PE can modify the data of that memory block by issuing a Store-Exclusive instruction.
When a memory block is marked as Open Access for a PE, this means that this PE cannot modify the data of that memory block by issuing a Store-Exclusive instruction.
ARMv8 gives different state machine diagrams for local monitor and global monitor. I cut these figures directly from Spec because I thought it was clear enough to understand.
Marked_address
in the figures is a memory block. You can figure it out by reading Exclusives Reservation Granule.*
at the end are IMPLEMENTATION DEFINED, so I don't think it's necessary to focus more on them, unless you want to design an ARMv8 based CPU.This section introduces some of the key elements in the synchronization model.
There are three types of synchronization primitives:
0
is returned to a register.1
is returned to a register.Transaction Size | Additional Semantics | Load-Exclusive | Store-Exclusive | Others |
---|---|---|---|---|
Byte | - | LDXRB | STXRB | - |
Load-Acquire/Store-Release | LDAXRB | STLXRB | - | |
Halfword | - | LDXRH | STXRH | - |
Load-Acquire/Store-Release | LDAXRH | STLXRRH | - | |
Register | - | LDXR | STXR | - |
Load-Acquire/Store-Release | LDAXR | STLXR | - | |
Pair | - | LDXP | STXP | - |
Load-Acquire/Store-Release | LDAXP | STLXP | - | |
None | Clear-Exclusive | - | - | CLREX |
Except for the row showing the CLREX instruction, the two instructions in a single row are a Load-Exclusive/ Store-Exclusive instruction pair.
The are two types of memory:
Non-Shareable
memory Shareable
memory
When the PE executes the Load-Exclusive instruction to load
64-bit data from address A1, the memory block that includes A1 will be marked
for Exclusive Access. The size of this memory block is aligned
by exclusives reservation granule specified in the ARMv8 Spec.
Exclusives reservation granule is IMPLEMENTATION DEFINED in
the range 4
-512
words. And in some implements it can be read from
CTR register, e.g. CTR_EL0.
0x30
as shown below, the memory block [0x20, 0x3F]
will be marked as
Exclusive Access state.
The local monitor is located in the PE. It is designed to monitor the exclusive status of a memory block(3). No PE can directly change the exclusive state of memory blocks monitored by other PEs.
The global monitor can either reside within the PE, or exist as a secondary monitor at the memory interfaces. It is designed to synchronize between multiprocessor system. The global monitors monitor one memory block for each PE separately, as shown below.
M-A
and M-B
monitored by the global monitor in the
following figure may or may not be the same. If they are identical, either
PE is affected by the store operations issued by the other PE on the common
memory block. This is the key to achieve synchronization.