Synchronization primitives. STMicroelectronics STM32H7S3L8, STM32H7R3L8, STM32H7S7A8, STM32H7R3V8, STM32H7R3R8, STM32H7S3Z8, STM32H7S3I8, STM32H7S3V8, STM32H7S7Z8, STM32H7R7I8
Annons
Annons
PM0253 The Cortex-M7 processor
Address A
A+1
A+2
A+3
Figure 9. Little-endian format
7
Memory
0
Register lsbyte
31
B3
24 23
B2
16 15
B1
8 7
B0
0
B0
B1
B2
B3 msbyte
MSv39644V1
The instruction set support for the Cortex ® -M7 processor includes pairs of synchronization primitives . These provide a non-blocking mechanism that a thread or process can use to obtain exclusive access to a memory location. Software can use them to perform a guaranteed read-modify-write memory update sequence, or for a semaphore mechanism.
A pair of synchronization primitives comprises:
A Load-Exclusive instruction
Used to read the value of a memory location, requesting exclusive access to that location.
A Store-Exclusive instruction
Used to attempt to write to the same memory location, returning a status bit to a register. If this bit is:
0 it indicates that the thread or process gained exclusive access to the memory, and the write succeeds,
1 it indicates that the thread or process did not gain exclusive access to the memory, and no write was performed.
The pairs of Load-Exclusive and Store-Exclusive instructions are:
• The word instructions LDREX and STREX.
• The halfword instructions LDREXH and STREXH.
• The byte instructions LDREXB and STREXB.
Software must use a Load-Exclusive instruction with the corresponding Store-Exclusive instruction.
To perform an exclusive read-modify-write of a memory location, software must:
1.
Use a Load-Exclusive instruction to read the value of the location.
2. Modify the value, as required.
3. Use a Store-Exclusive instruction to attempt to write the new value back to the memory location.
4. Test the returned status bit. If this bit is:
0: The read-modify-write completed successfully.
1: No write was performed. This indicates that the value returned at step 1 might be out of date. The software must retry the entire read-modify-write sequence.
PM0253 Rev 5 37/254
51
Ladda ner
Annons