In computer science, readâÂÂmodifyâÂÂwrite is a class of atomic operations (such as test-and-set, fetch-and-add, and compare-and-swap) that both read a memory location and write a new value into it simultaneously, either with a completely new value or some function of the previous value. These operations prevent race conditions in multi-threaded applications. Typically they are used to implement mutexes or semaphores. These atomic operations are also heavily used in non-blocking synchronization.
ReadâÂÂmodifyâÂÂwrite instructions often produce unexpected results when used on I/O devices, as a write operation may not affect the same internal register that would be accessed in a read operation. This term is also associated with RAID levels that perform actual write operations as atomic readâÂÂmodifyâÂÂwrite sequences. Such RAID levels include RAIDà4, RAIDà5 and RAIDà6.