SPRUJ79 November 2024 F29H850TU
The ATOMIC.M, or atomic, operation executes a protected sequence of memory operations while preventing other memory initiators from interrupting. This sequence can involve reading and updating shared variables in memory, where there is a need to protect these variables from updates by other initiators. The CPU atomic operation feature is typically used to implement a mutex or semaphore operation on shared data.
For true atomic CPU operations, the atomic operation must extend to memory accesses. The arbitration is locked to the CPU doing the atomic operations as soon as access is granted to the CPU. This can be a read or write operation. The lock is released when both signals transition low. From this point, other initiators can access the memory. This is visualized in Figure 3-19.
The CPU atomic operation extends to a maximum of 256 instruction packets. For atomic operations, reads are always directed to the memory controller to fetch the latest data from memory to make sure the latest data is being returned.
The arbitration lock is removed if the corresponding CPU enters a halt state. This prevents other initiators from being stalled forever and causing the CPU timeout checkers to generate a fault in the case where a CPU is halted. For this reason, atomic operations among initiators is not specified under debug scenarios. To maintain an atomic sequence during debug the DBGM control must be used to mark the atomic sequence as non-haltable.
Read-modify-write and memory-to-memory data move CPU instruction types are treated as regular reads and writes by the MEMSS. To have these operations treated as a protected sequence, the instructions need to be explicitly included in an atomic section of the code.
More than one memory controller can be locked to a CPU if the atomic block of code accesses more than one memory block. The lock is released simultaneously for MEMSS memory controllers at the end of an atomic sequence. If there are back-to-back atomic blocks being executed on a CPU, the MEMSS memory controller can be locked to that CPU through all blocks of code.
If a CPU has both an atomic read and atomic write, the access arbitration follows the fixed priority scheme. If two or more CPUs have atomic accesses, the arbitration is locked to one CPU and moves round-robin among the other CPUs. When some CPUs have non-atomic accesses, the accesses are serviced in between each access in the round-robin scheme. For example, if CPU1 has an atomic access, CPU2 has a non-atomic access, and CPU3 has an atomic access, and CPU1 is currently being serviced with an atomic lock, then one access for CPU2 is serviced followed by an atomic lock for CPU3.