CPSC 3220 - DAY 15 NOVEMBER 9, 2017 ================================================================================ CHAPTER 9 --------- Cache - Copy of data that is faster than access to the original Cache block - unit of chache storage (multiple memory locations) Temporal locality - programs tend to reference the same memory locations multiple times (ex instructions in a loop) Spatial locality - programs tend to reference nearby locations (data in a loop) Cache Concecpt (Read) CACHE +-------------------------+ FETCH | | FETCH ADDRESS | Address in | ADDRESS ---------------->| Cache? |NO -------------------------> | | | | +-------------------------+ YES | | STORE VALUE IN CACHE | | v Cache Concept (Write) CACHE +-------------------------+ STORE VALUE STORE | | FETCH AT ADDRESS | | VAL@ADDR | Address in | ADDRESS ----------->| |--------->| Cache? |NO---------------------> |_| | | WRITE | | BUFFER +-------------------------+ YES | | STORE VALUE IN CACHE | | STORE VALUE v AT ADDRESS IF WRITE THROUGH ---------------------------> Hardware address translation is a powerful tool ----------------------------------------------- Kernel trap on read/write to selected addresses -Copy on write -Fill on reference -Zero on use -Demand paged virtual memory -Memory mapped files -Modified bit emulation -Use bit emulation Allocating a Page Frame ----------------------- -Select old page to evict -Find all page table entries that refer to old page -If page frame is shared -Set each page table entry to invalid -Remove any TLB entries -Copies of now invalid page table entry -Write changes on page back to disk, if necessary Most machines keep dirty/use bits on page table entry Physical page is: -Modified if any page table entry that points to it is modifies -Recently used if any page table entry that points to it if it is recently used