Docsity

Virtual Memory & Memory Protection in OS: Inverted Page Tables & Segmentation - Prof. Jona, Study notes of Operating Systems

Partial preview of the text

Download Virtual Memory & Memory Protection in OS: Inverted Page Tables & Segmentation - Prof. Jona and more Study notes Operating Systems in PDF only on Docsity!

CS 333

Introduction to Operating Systems

Class 12 - Virtual Memory (2)

Jonathan Walpole Computer Science Portland State University

Inverted page tables

‰ Problem: ™ Page table overhead increases with address space size ™ Page tables get too big to fit in memory! ‰ Consider a computer with 64 bit addresses ™ Assume 4 Kbyte pages (12 bits for the offset) ™ Virtual address space = 2 52 pages! ™ Page table needs 2 52 entries! ™ This page table is much too large for memory!

Inverted page tables

How many mappings do we need (maximum) at any time? We only need mappings for pages that are in memory! ™ A 256 Mbyte memory can only hold 64 4Kbyte pages ™ Only need 64 page table entries on this computer!

Inverted page tables

‰ An inverted page table ™ Has one entry for every frame of memory ™ Records which page is in that frame ™ Is indexed by frame number not page number! ‰ So how can we search an inverted page table on a TLBmiss fault?

Inverted page tables

‰ If we have a page number (from a faulting address) andwant to find it page table entry, do we ™ Do an exhaustive search of all entries? ™ No, that’s too slow! ™ Why not maintain a hash table to allow fast access givena page number?

O(1) lookup time with a good hash function

Inverted page table

‰

Memory protection

‰ Protection though addressability ™ If address translation only allows a process to access itsown pages, it is implementing memory protection ‰ But what if you want a process to be able to read andexecute some pages but not write them? ™ text segment ‰

Or read and write them but not execute them?

™

stack

‰ Need some way of implementing protection based onaccess type

Memory protection

‰ How is protection checking implemented? ™ compare page protection bits with process capabilitiesand operation types on every load/store ™ sounds expensive! ™ Requires hardware support! ‰ How can protection checking be done efficiently? ™ Use the TLB as a “protection” look-aside buffer as wellas a translation lookaside buffer ™ Use special segment registers

Page-grain protection checking with a TLB

Page grain protection in a page table

A typical page table entry with support for

page grain protection

Segment-grain protection

‰ All pages within a segment usually share the same protectionstatus ™ So we should be able to batch the protection information ‰

Then why not just use segment-size pages?

Segment-grain protection

‰ All pages within a segment usually share the same protectionstatus ™ So we should be able to batch the protection information ‰

Then why not just use segment-size pages?

™ Segments vary in size from process to process ™ Segments change size dynamically (stack, heap etc) ‰

Need to manage addressability and access-basedprotection separately from memory allocation

Segmentation in a single address space

Example: ‰ A compiler

Segmented memory

‰ Each space grows, shrinks independently!