Section 9.5.6. ---------------------------------------------------------------------------- Topic 1: how does MMU find a page table entry. Short answer: depends on the page table structure. Example 1: the SPARC architecture, three-level page table. Context number --> context table; Example 2: Inverted page tables. use hash tables to speed look-up. Example 3: Two-level paging in the VAX. (You can page the page tables!) ------------------------------------------------------------------------------ Topic 2: page replacement algorithm. First, let's go through the exam question: 0 2 1 3 5 4 6 3 7 4 7 3 3 5 5 3 1 1 1 7 2 3 4 1 FIFO: ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ --> 13 page faults LRU: ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ --> 13 page faults MIN: ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ --> 10 page faults How do we implement the page replacement algorithms? - FIFO: easy. - LRU: - MIN: can't do. LRU approximations: (section 9.5.4) - multiple reference bits: shift bits at each clock tick; Example: suppose 3 bits; 0 2 1 3 5 4 6 3 | 7 4 7 3 3 5 5 3 | 1 1 1 7 2 3 4 1 - single reference bits: the clock algorithm; Example: suppose we have five page frames, and in the reference sequence below 0 2 1 3 5 4 6 3 7 4 7 3 3 5 5 3 1 1 1 7 2 3 4 1 - FIFO with second chance; All page replacement: need reverse mapping; ------------------------------------------------------------------------------ Topic 3: write a page back to disk. - writing it: scheduling of the writes; (section 9.5.6) "free list" and recovering from the free list; high water mark and low water mark; - finding a place on disk: swap allocation; - static allocation; - dynamic allocation; - remembering where it is on disk: | page table entry | disk block descriptor | disk block descriptor: swap dev number | block num | type (swap, file) ------------------------------------------------------------------------------ Topic 4: getting it off the disk: - finding out where it is on disk; - issue the read; - possibly prefetch; ----------------------------------------------------------------------------- Section 9.5.6 Kernel maintains a set of data structures for the physical pages, indicating whether a physical page is currently in use, or is free and can be replaced, or is being swapped out. Basic data structures that the kernel uses: . page list: a list of records indicating physical pages that holds a valid virtual page and is currently in use; . free pool: a list of records indicating physical pages that can be replaced; each of the pages on the free pool list may still hold a valid virtual page, but the virtual-to-physical translation of that virtual page is set to be invalid; . swap-out list: a list of records indicating physical pages that need to be written out to disk, that is, they hold some virtual pages that are "dirty" (have been changed) and those virtual pages need to be written out to disk. "Reclaim" from free pool: if a page fault occurs, and the physical page holding the virtual page is actually in the free pool, and the physical page hasn't been used to hold other virtual pages, then the physical page is taken out of the free pool and put back onto the page list. This is called "reclaim" from the free pool.