RMW command
In computer science, a read-modify-write command ( RMW command, English for read-modify-write ) denotes an atomic processor command that loads (read) a data value from memory , changes it by means of a calculation (modify) and the stores the changed value in a memory location, often the same, again (write) . In a broader sense, the term is also used for analog operations with processor registers and operations without modification (e.g. shift instructions).
Since the instruction is an atomic operation , it is ensured that the memory location is not changed by processes running in parallel during the modification . This property is used to implement locking objects such as semaphores and mutexes .
Implementations
Depending on the computer architecture , the RMW command is implemented as a combined read / write command or as a command pair. On RISC architectures, this operation is usually implemented as a load-link / store-conditional command pair, since the RISC philosophy does not allow combined RMW commands. On CISC architectures such as the Intel x86 processors, the combined compare-and-swap command is the primary RMW command.
An example of an early processor with RMW instructions is the 6502 from the 1970s. Although he was not yet able to make any modifications, he still had the option of counting up (INCrement) or counting down (DECrement) a memory location with the INC and DEC commands .