tutorial 8
Download
Skip this Video
Download Presentation
Tutorial 8

Loading in 2 Seconds...

play fullscreen
1 / 18

Tutorial 8 - PowerPoint PPT Presentation


  • 209 Views
  • Uploaded on

Tutorial 8. Virtual Memory: PAGING presented by: Antonio Maiorano Paul Di Marco. 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. Process Location.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Tutorial 8' - keelia


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
tutorial 8

Tutorial 8

Virtual Memory: PAGING

presented by:

Antonio Maiorano

Paul Di Marco

paging
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
process location
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
what s the point
What’s the point?
  • Many more processes can run at the same time
  • Works well because:
    • “Reference locality behaviour”
    • Well-supported by hardware
how does it work
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 =
  • Ex: 32 bits = <24 bits, 8 bits>= <16777216 pages, 256 locations per page>
in the cpu
In the CPU

Virtual Address

Page #

Offset #

Missing

Page

MAP

Frame #

Offset #

Physical Address

page reference stream
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
static paging algorithms
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
3 basic paging policies
3 Basic Paging Policies
  • Fetch Policy: determines when a page should be loaded into RAM
  • Replacement Policy: if all frames are full, determines which page should be replaced
  • Placement Policy: determines where a fetched page should be placed in RAM
demand paging
Demand Paging
  • Since the page reference stream is not known ahead of time, we can’t “pre-fetch” pages
  • We know which page to load during run-time so we load them on “demand”
  • Result: concentrate on replacement policies (#3)
demand paging algorithms

Demand Paging Algorithms

Random, Optimal,

LRU, LFU, FIFO

random replacement
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
optimal algorithm
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
optimal algorithm example
0

1

2

3

0

1

2

3

0

1

2

3

4

5

6

7

0

0

0

0

0

0

0

0

0

1

1

1

4

4

4

7

fr 0

1

1

1

1

1

2

2

2

2

2

2

2

5

5

5

fr 1

fr 2

2

3

3

3

3

3

3

3

3

3

3

3

6

6

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
least recently used lru
0

1

2

3

0

1

2

3

0

1

2

3

4

5

6

7

0

0

0

3

3

3

2

2

2

1

1

1

4

4

4

7

fr 0

1

1

1

0

0

0

3

3

3

2

2

2

5

5

5

fr 1

fr 2

2

2

2

1

1

1

0

0

0

3

3

3

6

6

Least Recently Used (LRU)
  • Replace the page which was last referenced the longest time ago
least frequently used lfu
0

1

2

3

0

1

2

3

0

1

2

3

4

5

6

7

0

0

3

3

0

0

3

3

0

0

0

0

0

0

0

3

fr 0

1

1

1

1

1

1

1

1

1

3

1

1

1

3

1

fr 1

fr 2

6

5

4

7

2

2

3

2

3

3

2

2

2

2

Least Frequently Used (LFU)
  • Replace the page which was least frequently referenced (since the beginning of the reference stream)
first in first out fifo
0

1

2

3

0

1

2

3

0

1

2

3

4

5

6

7

0

0

0

3

3

3

2

2

2

1

1

1

4

4

4

7

fr 0

1

1

1

0

0

0

3

3

3

2

2

2

5

5

5

fr 1

fr 2

2

2

2

1

1

1

0

0

0

3

3

3

6

6

First In First Out (FIFO)
  • Replace the page that has been in memory longest
comparison of the samples
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
ad