讀-修改-寫(read-modify-write)是電腦科學中的一個原子操作(atomic operation,類似的還有test-and-set, fetch-and-add, compare-and-swap等),操作過程是讀一個主記憶體位置(或IO埠),修改其值,再寫回原位置。[1][2]
必須要先讀操作的一個原因是,系統架構往往只允許字(word)級的讀寫,必須先讀出那些不做修改的位元,保持不變再寫回。寫成C語言陳述式類似於:
*pRegister |= SOME_BIT;
Read-modify-write指令用於IO埠時,可能會產生出乎意料的結果,如無法給一個位元置位。這往往是因為寫操作並不影響到讀操作的源暫存器。[3]
RAID也使用這一術語描述原子操作的read-modify-write序列。[4] Such RAID levels include RAID 4, RAID 5 and RAID 6.
參見
- 可線性化
- Read-erase-modify-write
參考文獻
Wikiwand in your browser!
Seamless Wikipedia browsing. On steroids.
Every time you click a link to Wikipedia, Wiktionary or Wikiquote in your browser's search results, it will show the modern Wikiwand interface.
Wikiwand extension is a five stars, simple, with minimum permission required to keep your browsing private, safe and transparent.