| Managing cache: issues | |||||||||||||
| Cache misses: types | |||||||||||||
| compulsory: first reference to a data item | |||||||||||||
| capacity: not enough space in cache | |||||||||||||
| too few slots | |||||||||||||
| cache line too small | |||||||||||||
| conflict: space is available, but data block already stored at that location | |||||||||||||
| 2 cache lines map to same cache slot | |||||||||||||
| Instruction and data cache | |||||||||||||
| instructions and data have different access patterns, use different memory areas | |||||||||||||
| use separate instruction and data caches | |||||||||||||
| one reason to have separate instruction and data memories in datapath | |||||||||||||
| Modifying data in the cache | |||||||||||||
| write-back: update main memory only when block is removed from cache | |||||||||||||
| saves time required to write main memory for each store | |||||||||||||
| write-through | |||||||||||||
| update main memory at the same time as cache | |||||||||||||
| save time by continuing execution while main memory write completes | |||||||||||||
| Replacement policy | |||||||||||||
| how to choose cache line to replace | |||||||||||||
| LRU: least recently used: slot which has not been used in the longest time | |||||||||||||
| LFU: least frequently used | |||||||||||||
| FIFO: first in, first out: slot which has been in the cache the longest | |||||||||||||
| Random: may be only 10% worse than LRU | |||||||||||||
| may require additional hardware to keep track | |||||||||||||