📜  区分直写和回写方法

📅  最后修改于: 2021-06-28 17:10:37             🧑  作者: Mango

前提条件–直写和写回缓存

在读取操作期间,当CPU确定高速缓存中的字时,主存储器不包括在传输中。因此,当操作是写操作时,系统可以通过两种方式进行处理。

1.直写方法:最简单的方法是,当高速缓存在指定地址包含字时,并行更新缓存时,将通过每次内存写入操作来更新主内存。这可以称为直写方法。

2.回写方法:
在写操作期间,在写回方法中仅更新缓存位置。然后,用标记标记该位置,以便在从高速缓存中删除该字时将其复制到主存储器中。对于回写方法,原因是在单词保留在高速缓存中的时间内,它可以被多次更新。因此,只要单词保留在高速缓存中,副本是否在主高速缓存中都没有关系。只有当单词从高速缓存中移出时,该高速缓存需要将精确的副本重写到主存储器中。

区分直写和回写方法:

S.No. Write Through Method Write Back Method
1 In this method main memory is updated with every memory write operation as well as cache memory is updated in parallel if it contains the word at the specified address. In this method only cache location is updated during write operation.
2 Main memory always contains same data as cache. Main memory and cache memory may have different data.
3 Number of memory write operation in a typical program is more. Number of memory write operation in a typical program is less
4 When I/O device communicated through DMA would receive most recent data. When I/O device communicated through DMA would not receive most recent data.
5 It is a process of writing cache and main memory simultaneously. It is a process of writing cache and data is removed from cache, first copied to main memory.