回写与直写缓存? [英] Write-back vs Write-Through caching?

查看:24
本文介绍了回写与直写缓存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的理解是这两种方法的主要区别在于直写"方法数据立即通过缓存写入主存储器,而在回写"中数据是在稍后"写入的.

My understanding is that the main difference between the two methods is that in "write-through" method data is written to the main memory through the cache immediately, while in "write-back" data is written in a "later time".

我们仍然需要在稍后"等待内存那么直写"有什么好处?

We still need to wait for the memory in "later time" so What is the benefit of "write-through"?

推荐答案

直写到主存的好处是它简化了计算机系统的设计.通过直写,主存储器始终具有该行的最新副本.所以当读取完成时,主存总是可以回复请求的数据.

The benefit of write-through to main memory is that it simplifies the design of the computer system. With write-through, the main memory always has an up-to-date copy of the line. So when a read is done, main memory can always reply with the requested data.

如果使用回写,有时最新数据在处理器缓存中,有时在主内存中.如果数据在处理器缓存中,那么该处理器必须停止主内存回复读取请求,因为主内存可能有数据的陈旧副本.这比直写更复杂.

If write-back is used, sometimes the up-to-date data is in a processor cache, and sometimes it is in main memory. If the data is in a processor cache, then that processor must stop main memory from replying to the read request, because the main memory might have a stale copy of the data. This is more complicated than write-through.

此外,直写可以简化缓存一致性协议,因为它不需要 Modify 状态.Modify 状态记录缓存必须在使缓存行无效或驱逐之前写回缓存行.在直写中,高速缓存行总是可以在不回写的情况下失效,因为内存已经拥有该行的最新副本.

Also, write-through can simplify the cache coherency protocol because it doesn't need the Modify state. The Modify state records that the cache must write back the cache line before it invalidates or evicts the line. In write-through a cache line can always be invalidated without writing back since memory already has an up-to-date copy of the line.

还有一件事 - 在写回内存映射 I/O 寄存器的回写架构软件上,必须采取额外的步骤来确保写入立即从缓存中发送出去.否则,在其他处理器读取该行或该行被逐出之前,在内核外无法看到写入.

One more thing - on a write-back architecture software that writes to memory-mapped I/O registers must take extra steps to make sure that writes are immediately sent out of the cache. Otherwise writes are not visible outside the core until the line is read by another processor or the line is evicted.

这篇关于回写与直写缓存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆