1. write through
直写式(write through),也叫写透,即CPU在向Cache写入数据的同时,也把数据写入主存以保证Cache和主存中相应单元数据的一致性。
其特点是简单可靠,但由于CPU每次更新时都要对主存写入,速度必然受影响。
write throgh:In a write-through cache, data is writen to main memory at the sam e time as the cache is updated.
cache的数据update后,main mem的数据同时update
2. write back
回写式(write back)即CPU只向Cache写入,并用标记加以注明,直到Cache中被写过的块要被进入的信息块取代时,才一次写入主存。这种方式考虑到写入的往往是中间结果,每次写入主存速度慢而且不必要。
其特点是速度快,避免了不必要的冗余写操作,但结构上较复杂。
write back (also known as copyback):In a write-back cache, data is only written to main memory when it is forced out of the cache on line replacement following a cache miss. Otherwise, writes by the processor only update the cache.
cache的数据update后,main mem的数据不同时update(cache line 被称为dirty);直到cache数据要被替换时时,才将main mem的数据 update(cache line被称为clean)
参考链接: