CS 241 Fall 2007: System Programming - Memory Paging and Replacement, Study notes of Computer Science

An overview of memory paging and replacement concepts in system programming. Topics include two-level paging, inverted page tables, sharing and protection, demand paging, and page replacement strategies. The document also discusses the principle of optimality and its application to page replacement.

Typology: Study notes

Pre 2010

Uploaded on 03/16/2009

koofers-user-ze1
koofers-user-ze1 🇺🇸

10 documents

1 / 23

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CS 241 Fall 2007
System Programming
1
Memory Paging and Replacement
Lawrence Angrave
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17

Partial preview of the text

Download CS 241 Fall 2007: System Programming - Memory Paging and Replacement and more Study notes Computer Science in PDF only on Docsity!

CS 241 Fall 2007 System Programming

Memory Paging and Replacement

Lawrence Angrave

Concepts this Lecture Two-Level Paging Example Inverted Page Table Sharing and Protection Introduction to Demand Paging

Addressing on Two-Level Page Table 32-bit Architecture, 4096= 2^12 Bytes Page Size 4K Page of Logical Memory has 4096 addressable bytes Page the Page Table with 4K pages as well 4K Page of Page Table has 1024 addressable 4byte addresses

Multilevel Paging and Performance Since each level is stored as a separate table in memory, converting a logical address to a physical one with a three-level page table may take four memory accesses. Why?

Inverted Page Table 004 006 005 006

Page Table Virtual Address (004006) Physical Address (005006)

Inverted Page Table Implementation TLB is same as before TLB miss is handled by software In-memory page table is managed using a hash table Number of entries ≥ number of physical frames Not found: page fault Hash table Virtual page (^) Physical page

Inverted Page Table Decreases memory needed to store each page table, but increases time needed to search table when a page reference occurs. Use hash table to limit the search to one -- or at most a few page-table entries.

Sharing Pages Code and data can be shared by mapping them into pages with common page frame mappings. Code and data must be position independent if VM mappings for the shared data are different.

Protection Can add read, write, execute protection bits to page table to protect memory. Check is done by hardware during access. Can give shared memory location different protections from different processes by having different page table protection access bits.

Page Protection Legend: reference - page has been accessed valid - page exists resident - page is cached in primary memory dirty - page has been changed since page in

Demand Paging Algorithm Never bring a page into primary memory until its needed. Page fault Check if a valid virtual memory address. Kill job if not. If valid reference, check if its cached in memory already (perhaps for some other process.) If so, skip to 7). Find a free page frame. Map address into disk block and fetch disk block into page frame. Suspend user process. When disk read finished, add vm mapping for page frame. If necessary, restart process.

Demand Paging Example Load M i Free frame Page table VM ref fault

Issue: Eviction Hopefully, kick out a less-useful page Dirty pages require writing, clean pages don’t Hardware has a dirty bit for each page frame indicating this page has been updated or not Where do you write? To “swap space” Goal: kick out the page that’s least useful Problem: how do you determine utility? Heuristic: temporal locality exists Kick out pages that aren’t likely to be used again

Terminology Reference string : the memory reference sequence generated by a program. Paging – moving pages to (from) disk Optimal – the best (theoretical) strategy Eviction – throwing something out Pollution – bringing in useless pages/lines