Virtual Memory: PAGING - PowerPoint PPT Presentation

1 / 18
About This Presentation
Title:

Virtual Memory: PAGING

Description:

... Paging System must be able to translate each virtual address into a physical ... We know which page to load during run-time so we load them on 'demand' ... – PowerPoint PPT presentation

Number of Views:266
Avg rating:3.0/5.0
Slides: 19
Provided by: antoniom6
Category:

less

Transcript and Presenter's Notes

Title: Virtual Memory: PAGING


1
Tutorial 8
  • Virtual Memory PAGING
  • presented by
  • Antonio Maiorano
  • Paul Di Marco

2
Paging
  • Primary Memory (RAM) is divided into fixed size
    partitions we call frames
  • Processes also divided into same sized partitions
    we call pages
  • Result almost no fragmentation

3
Process Location
  • Most of the process is on Secondary Memory (HD)
  • Some of the process pages are loaded into frames
    in RAM
  • In RAM, the frames allocated to a process need
    not be contiguous
  • Uses a page table to map pages to frames

4
Whats the point?
  • Many more processes can run at the same time
  • Works well because
  • Reference locality behaviour
  • Well-supported by hardware

5
How does it work?
  • For each memory reference, Paging System must be
    able to translate each virtual address into a
    physical address at run-time
  • Address ltpage/frame num, offsetgt
  • Ex 32 bits lt24 bits, 8 bitsgt lt16777216
    pages, 256 locations per pagegt

6
In the CPU
Page
Offset
Virtual Address
Missing Page
MAP
Frame
Offset
Physical Address
7
Page Reference Stream
  • For a given process, the page reference stream is
    the list of virtual page numbers ordered
    according to when they are referenced
  • Example Process with 5 pages 1, 2, 3, 1, 2,
    3, 4, 5

8
Static Paging Algorithms
  • When process starts, it is allocated a fixed
    number of frames in RAM
  • Paging Policies defines how pages will be
    loaded/unloaded into frames allocated to the
    process

9
3 Basic Paging Policies
  1. Fetch Policy determines when a page should be
    loaded into RAM
  2. Replacement Policy if all frames are full,
    determines which page should be replaced
  3. Placement Policy determines where a fetched page
    should be placed in RAM

10
Demand Paging
  • Since the page reference stream is not known
    ahead of time, we cant pre-fetch pages
  • We know which page to load during run-time so we
    load them on demand
  • Result concentrate on replacement policies (3)

11
Demand Paging Algorithms
  • Random, Optimal,
  • LRU, LFU, FIFO

12
Random Replacement
  • Choose a page at random to be the victim page
  • Simple to implement, but is the worst algorithm
  • No knowledge is taken into account!
  • Each page thus has same probability of being the
    victim

13
Optimal Algorithm
  • Best algorithm however requires knowledge of the
    future page references (!)
  • Always results in least possible page faults
  • Replace the page that will be referenced the
    latest from now

14
Optimal Algorithm Example
  • The process reference stream is
  • 0 1 2 3 0 1 2 3 0 1 2 3 4 5 6 7
  • The process is allocated 3 frames

15
Least Recently Used (LRU)
  • Replace the page which was last referenced the
    longest time ago

16
Least Frequently Used (LFU)
  • Replace the page which was least frequently
    referenced (since the beginning of the reference
    stream)

17
First In First Out (FIFO)
  • Replace the page that has been in memory longest

18
Comparison of the samples
  • For the same reference stream and number of
    available frames
  • Optimal caused 10 page faults
  • LRU caused 16 page faults
  • LFU caused 12 page faults
  • FIFO caused 16 page faults
Write a Comment
User Comments (0)
About PowerShow.com