Background

Diagram
Diagram showing virtual memory that is larger than physical memory
Addr
Virtual address space of a process in memory
Share
Shared library using virtual memory

Demand Paging

PageTable
Page table when some pages are not in main memory
PageFault
Steps in handling a page fault

Pure Demand Paging

Locality of Reference

// 1
int i, j;
int[128][128] data;

for (j = 0; j < 128; ++j)
    for (i = 0; i < 128; ++i)
        data[i][j] = 0;

// 2
int i, j;
int[128][128] data;

for (i = 0; i < 128; ++i)
    for (j = 0; j < 128; ++j)
        data[i][j] = 0;

Hardware Support to Demand Paging

Instruction Restart

Free Frame List

List
List of free frames

Performance of Demand Paging

Copy-on-Write

Before
Before process 1 modifies page C
After
After process 1 modifies page C

Page Replacement

Need
Need for page replacement
PR
Page replacement

Evaluation of Page Replacement Algorithms

Graph
Graph of page faults versus number of frames
Ex

FIFO Page Replacement

FIFO
FIFO page-replacement algorithm

Belady’s Anomaly

Graph
Page-fault curve of FIFO replacement on a reference string

Optimal Page Replacement

OPT
Optimal page-replacement algorithm

LRU Page Replacement

LRU
LRU page-replacement algorithm
LRU
Use of a stack to record the most recent page reference

Second-Chance Algorithm

SC
Second-chance (clock) page-replacement algorithm

Allocation of Frames

Thrashing

Thrashing
Thrashing

Working-Set Model

Locality
Locality in a memory-reference pattern
Working
Working-set model