Differences between disk Cache Write-through and Write-back

3 篇文章 0 订阅

目录

BACKGROUND INFORMATION

HANDLING METHOD FOR WRITE-MISSES

FLOWCHARTS


This post brings you the topic of differences between disk Cache Write-through and Write-back. Please find more information as you read further down the post.

BACKGROUND INFORMATION

The cache mechanism includes write-through and write-back.

Write-through: Write is done synchronously - both to the cache and to the backing store.

Write-back (or Write-behind): Writing is done only to the cache. A modified cache block is written back to the store, just before it is replaced.

Write-through: When data is updated, it is written to both the cache and the back-end storage. This mode is easy to slow in data writing because data has to be written to both the cache and the storage.


Write-back: When data is updated, it is written only to the cache. The modified data is written to the back-end storage only when data is removed from the cache. This mode has fast data write data will be lost if a power failure occurs before the updated data is written to the storage.


HANDLING METHOD FOR WRITE-MISSES

CPU读Cache时

●若hit,则CPU直接从Cache中读取数据即可。

●若miss,有两种处理方式:

   >Read through,即直接从内存中读取数据;

   >Read allocate,先把数据读取到Cache中,再从Cache中读数据。

写操作

先检查cache里是否有对应数据,如果有(write hit):

根据是write-back还是write-through来具体操作:

write-back:将数据更新到cache,并不更新到内存(DRAM),待后续flush cache时存入内存;

write-through:数据同时会更新到cache和内存;

如果没有(write miss):

Two methods are available for handling write-misses.

根据是write-allocate或是write-no-allocate:

write-allocate:将要写入的位置从内存读到cache,然后按照上述write hit继续操作;

write-no-allocate:不会将要写入的数据从内存读到cache,直接将要写的数据写入内存。


Both Write-through and Write-back can use Write allocate or No-write allocate. Typically, Write-back uses Write allocate and Write-through No-write allocate, because Write allocate improves performance for Write-not for Write-through when data is written to one cache for multiple times.


FLOWCHARTS

Figure 1. Write-through flowchart: A Write-through cache with No-write allocate

Figure 2. Write-back flowchart: A Write-back cache with Write

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值