zoukankan      html  css  js  c++  java
  • Cache写机制:Writethrough与Writeback

    Writing policies

    A Write-Through cache with No-Write Allocation

    A Write-Back cache with Write Allocation

    When a system writes a datum to cache, it must at some point write that datum to backing store as well. The timing of this write is controlled by what is known as the write policy.

    There are two basic writing approaches:

    • 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同时更新cache和后端存储

    write-back 只写cache。当cache blokc要被替换时,才写到后端存储。

    Write-back cache is more complex to implement, since it needs to track which of its locations have been written over, and mark them as dirty for later writing to the backing store. The data in these locations are written back to the backing store only when they are evicted from the cache, an effect referred to as a lazy write. For this reason, a read miss in a write-back cache (which requires a block to be replaced by another) will often require two memory accesses to service: one to write the replaced data from the cache back to the store, and then one to retrieve the needed datum.

    Other policies may also trigger data write-back. The client may make many changes to a datum in the cache, and then explicitly notify the cache to write back the datum.

    Since on write operations, no actual data are needed back, there are two approaches for situations of write-misses:

    • Write allocate (aka Fetch on write) - Datum at the missed-write location is loaded to cache, followed by a write-hit operation. In this approach, write misses are similar to read-misses.
    • No-write allocate (aka Write-no-allocate, Write around) - Datum at the missed-write location is not loaded to cache, and is written directly to the backing store. In this approach, actually only system reads are being cached.

    Both write-through and write-back policies can use either of these write-miss policies, but usually they are paired in this way:[2]

    • A write-back cache uses write allocate, hoping for subsequent writes (or even reads) to the same location, which is now cached.
    • A write-through cache uses no-write allocate. Here, subsequent writes have no advantage, since they still need to be written directly to the backing store.

    Entities other than the cache may change the data in the backing store, in which case the copy in the cache may become out-of-date or stale. Alternatively, when the client updates the data in the cache, copies of those data in other caches will become stale. Communication protocols between the cache managers which keep the data consistent are known as coherency protocols.

  • 相关阅读:
    3 Steps to Perform SSH Login Without Password Using sshkeygen & sshcopyid
    排序算法java版,速度排行:冒泡排序、简单选择排序、直接插入排序、折半插入排序、希尔排序、堆排序、归并排序、快速排序
    Ubuntu 取消 Apache及MySQL等自启动
    linux screen 命令详解
    Ubuntu把家目录文件夹名称改为英文
    Ubuntu12.10 下 PPA安装搜狗输入法 for Linux
    VirtualBox虚拟机后台运行
    Ubuntu下安装jdk
    [整理篇]linux加入windows域之完美方案
    pxe 远程安装linux系统
  • 原文地址:https://www.cnblogs.com/cute/p/2582916.html
Copyright © 2011-2022 走看看