ReadShared with exclusive access is used to read a location with the intention of updating the location. The same thing can be done using ReadUnique which ensures that the requester gets a unique copy that can then be modified. What is the difference between the two and when would one be used compared to the other?
Hi, apologies for the delay in replying to you. Please may you have a look at the list of Forums here: Support forums and let me know where is best to move your question to? Thanks.
Hi Annie, the Architecture and Processors forum ( Architectures and Processors forum ) seems to be the most appropriate forum for this question. Thanks.
Exclusive sequences are specifically a read modify write sequence, where the sequence guarantees that no other requesters will store to the location between the read and the write. If another requester does store to the location, then the exclusive sequence fails, the store is not performed and the sequence would need to be restarted. The Store part of the exclusive effectively becomes conditional on no other requesters storing to that location first.
The purpose of exclusives is to allow for synchronisation between different cores or different threads by allowing for a semaphore or lock to be created that enables mutual exclusion for critical sections of code.
Exclusive transactions correspond to LDXR and STXR Arm instructions.
In other words, the purpose of an exclusive ReadShared isn't primarily about trying to update a location. By contrast, a ReadUnique simply always returns data in a Unique state such that it can be written to. The purpose of a ReadUnique is to obtain a cache line so that a store can be performed.
Thanks Christopher for the detailed answer. Your answer seems to imply that using exclusive transactions (RMW) for synchronization is more efficient than getting the ownership of the line and writing back - effectively emulating the RMW. Is this understanding correct?
It's not not exactly about efficiency.
It's more that the Exclusive sequences gives you the ability to create semaphores or locks. In other words, if you wish to perform an Arm Architectural exclusive sequence, then you would use the exclusive sequence flow described in the CHI Specification.
A ReadUnique would be used in cases where no synchronisation is required and the PE simply wishes to write data into a memory location.
I think there is a misunderstanding regarding the use of the term "exclusive". In Arm and AMBA CHI, exclusive refers to load-exclusive/store-exclusive sequences which are used to perform atomic read/modify/write operations (the LSE atomics are usually better though). This is equivalent to LL/SC (load-linked/store-conditional) as used by other RISC architectures. The AMBA CHI state which corresponds to MESI exclusive state is called unique. A requester node (e.g. processor) must get a line in unique state in order to modify it. This can be done using the ReadUnique transaction (there are also other transactions that provide or materialise the line in unique state). A prefetch-for-store (PRFM PST) instruction can be used to get a line in unique state, preparing for a later update even if there are reads which precede the write. Those reads would otherwise have fetched the line in shared state (if line not already present in cache).
I suspect the ReadShared with exclusive access (note not unique) is used by load-exclusive (e.g. LDXR) to start an exclusives sequence. The processor gets the line in shared state but informs the Home Node that an exclusives sequence is in progress. The Home Node can use this information if other processors also start exclusive sequences for the same location or cache line. When the processor executes the store-exclusive instruction (e.g. STXR), it must get the line in unique state so that it can be updated. But if the line has been invalidated (since load-exclusive), store-exclusive will fail and software will have to handle the situation (usually by retrying the exclusives sequence).