Read-modify-write

A read-modify -write instruction ( RMW instruction, English for read-modify - write) referred to in the computer science an atomic processor instruction that loads a data value from memory (read ), changed him by a calculation (modify ) and the changed value to the same or another location in memory stores again ( write).

Since the instruction is an atomic operation, it is ensured that the location is not modified during the modification of parallel processes. This property is used for the implementation of semaphores and mutexes as Lockingobjekten.

Implementations

Depending on the computer architecture of the RMW command is implemented as a combined read / write command or instruction pair. On RISC architectures, this operation is usually implemented as Load-Link/Store-Conditional instruction pair, because the RISC philosophy does not allow combined RMW commands. On CISC architectures like the Intel x86 processors, the combined Compare- and- swap instruction is the primary RMW command.

An example of an early processor with RMW commands is the 6502 from the 1970's. Although he could not perform any modifications, but had with the commands INC and DEC at least the possibility of a memory location by one high ( INCrement ) or down counting ( decrement ).

685684
de