高速缓存中对高速缓存的读写分为:
通写(写通):write_through 是CPU写入高速缓存的数据同时也到写到主存中。
回写(写回):write_back 是CPU写入高速缓存的数据并不同步到主存中,当这些数据要被丢弃的时候才写回主存。
写时申请:write_allocate 是在CPU写cache未命中时,它会将数据写入主存,并将写入主存地址处的内存块放到高速缓存中,供CPU下次访问时使用。
具体请参考下面英文:
‘Write back’ means: If write-hit in cache, update cache contents only and delay updating memory. This idea is based on the Temporal Locality, for this address block we have just updated is highly probable that it would be updated (written) again in a short time period. If we only update the cache and update the memory only when it is necessary, we can reduce the frequency of writing memory, thus accelerates writing.
‘Write allocate’ mean: If write-not-hit in cache, update in memory and put the address block into cache afterwards. This idea is also based on the Temporal Locality, for the address block we have just updated is highly probable that it would be read in a short time period. If we put this block into cache, it would be much faster for the next reading step.
Now we can see some good reasons for their combination in usage.
1. Accelerate both read and write.
2. The important factor is, when we write something into memory by the ‘write back’ policy? The answer is: The time just before we need to read the contents in memory. Then, we are going to read the memory, so it is high time that we are eager to provide a read-hit cache block now! And the policy is exactly ‘write allocate’.
3. Another fundamental factor is that, if we start with a write-miss and the policy is ‘write allocate’, this block is going to appear in caches. Thus, if another write command comes, ‘write back’ policy can easily work on caches and save time accessing memory.
Similarly, we can analyze the ‘write-through’ policy and its combination with ‘no write allocate’. ‘Write through’ provides a real-time-updated memory and it is unnecessary to fetch the address block into cache any more. It matches the policy ‘no write allocate’
linux中对于所有的页框都启用高速缓存,对于写操作总是采用回写策略
阅读(2689) | 评论(0) | 转发(1) |