缓存更新之write through与write back

  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.

转载于:https://my.oschina.net/shelllife/blog/1537032

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值