virtual memory & paging algorithms

22
Virtual Memory & Paging Algorithms Chapter 4 Tuesday, March 26, 2007

Upload: reece

Post on 13-Jan-2016

65 views

Category:

Documents


0 download

DESCRIPTION

Virtual Memory & Paging Algorithms. Chapter 4 Tuesday, March 26, 2007. Today’s Schedule. Memory Management - Chapter 4 Managing Page Tables Multi-Level Page Tables Inverted Page Tables Page Replacement Algorithms NRU FIFO Second Chance Clock. Objectives. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Virtual Memory & Paging Algorithms

Virtual Memory & Paging Algorithms

Chapter 4

Tuesday, March 26, 2007

Page 2: Virtual Memory & Paging Algorithms

Today’s Schedule Memory Management - Chapter 4

Managing Page Tables Multi-Level Page Tables Inverted Page Tables

Page Replacement Algorithms NRU FIFO Second Chance Clock

Page 3: Virtual Memory & Paging Algorithms

Objectives

You will be able to describe: Trade-offs in page table implementation for

speed and space TLB Multi-level page tables Inverted page tables

The difference between page replacement policies first-in first-out not-recently-used page clock and second chance

Page 4: Virtual Memory & Paging Algorithms

Paging Overview

Page 5: Virtual Memory & Paging Algorithms

Paging Hardware With TLB

A TLB to speed up paging

Page 6: Virtual Memory & Paging Algorithms

TLBs – Translation Lookaside Buffers

An Item is missing in the TLB entry? Why?

Page 7: Virtual Memory & Paging Algorithms

Page Table Entry

Typical page table entry

Page 8: Virtual Memory & Paging Algorithms

Address Translation Scheme Address generated by CPU is divided into:

Page number (p) – used as an index into a page table which contains base address of each page in physical memory

Page offset (d) – combined with base address to define the physical memory address that is sent to the memory unit

For given logical address space 2m and page size 2n

page number page offset

p d

m - n n

Page 9: Virtual Memory & Paging Algorithms

How Big is a Page Table?

For 32-bit Address Space?? For 64-bit Address Space??

Page 10: Virtual Memory & Paging Algorithms

Multi-Level Page Tables

32 bit address with 2 page table fields Two-level page tables – save space!

Second-level page tables

Top-level page table

Page 11: Virtual Memory & Paging Algorithms

Inverted Page Table One entry for each real page of memory Entry consists of the virtual address of the page

stored in that real memory location, with information about the process that owns that page

Decreases memory needed to store each page table, but increases time needed to search the table when a page reference occurs

Use hash table to limit the search to one — or at most a few — page-table entries

Page 12: Virtual Memory & Paging Algorithms

Inverted Page Tables

Comparison of a traditional page table with an inverted page table

Page 13: Virtual Memory & Paging Algorithms

Allocating Free Frames

Before allocation After allocation

Page 14: Virtual Memory & Paging Algorithms

Page Replacement Algorithms Page fault forces choice

which page must be removedmake room for incoming page

Modified page must first be savedunmodified just overwritten

Better not to choose an often used pagewill probably need to be brought back in

soon

Page 15: Virtual Memory & Paging Algorithms

Optimal Page Replacement Algorithm

Replace page needed at the farthest point in futureOptimal but unrealizable

Estimate by … logging page use on previous runs of processalthough this is impractical

Page 16: Virtual Memory & Paging Algorithms

Not Recently Used Page Replacement

Each page has Reference bit, Modified bit bits are set when page is referenced,

modified Pages are classified

Class 0 - not referenced, not modified Class 1 - not referenced, modified Class 2 - referenced, not modified Class 3 - referenced, modified

NRU removes page at random from lowest numbered non empty class

Page 17: Virtual Memory & Paging Algorithms

FIFO Page Replacement Algorithm Maintain a linked list of all pages

in order they came into memory

Page at beginning of list replaced

Disadvantagepage in memory the longest may be often used

Page 18: Virtual Memory & Paging Algorithms

Ex. FIFO Page Replacement

Working of a FIFO algorithm for a job with four pages (A, B, C, D) as it’s processed by a system with only two available page frames

Page 19: Virtual Memory & Paging Algorithms

Second Chance Page Replacement

Operation of a second chance pages sorted in FIFO order Page list if fault occurs at time 20, A has R bit set

(numbers above pages are loading times)

Page 20: Virtual Memory & Paging Algorithms

The Clock Page Replacement Algorithm

Page 21: Virtual Memory & Paging Algorithms

Summary Trade-offs in page table implementation for

speed and space TLB in H/W Multi-level page tables Inverted page tables

The difference between page replacement policies first-in first-out not-recently-used page clock & second chance

Page 22: Virtual Memory & Paging Algorithms

Thursday, March 29

Assignment #7 Due Monday, April 2 Continue reading,

Chapter 4 – Memory Management Sec 4.4.8 Working SetSec 4.4.10 Summary of Page

ReplacementSec 4.5.1 Modeling Page Repl.Sec 4.8 Segmentation (pg 249-253)