缓存更新之write through与write back

原创
2017/09/13 21:10
阅读数 9.2K
  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)

  3. dirty:

    A cache line in a write-back cache that has been modified while it is in the cache is said to be dirty. A cache line is marked as dirty by setting the dirty bit. If a cache line is dirty, it must be written to memory on a cache miss because the next level of memory contains data that has not been updated. The process of writing dirdy data to main memory is called cache cleaning.

  4. clean:

    A cache line that has not been not modified while it is in the cache is said to be clean. To clean a cache is to write dirty cache entries into main memory.If a cache line is clean, it is not wirtten on a cache miss because the next level of memory contains the same data as the cache.

展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部