Lecture 18: Virtual Memory 2 Flashcards

1
Q

Policy #1: First-In-First-Out (FIFO)

A

Idea: Replace the page that’s been in memory the longest

\+: Easy to implement, understand
–: Ignores page usage
Suffers from Belady’s Anomaly: Available frames Þhit
ratio ¯
e.g.: 1 2 3 4 1 2 5 1 2 3 4 5
What is the hit ratio assuming:
a. 3 available frames
b. 4 available frames
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Policy #2: Optimal

A

Evict the page that won’t be needed for the longest time
+: can’t get a better hit ratio than this gives
–: there is no way to know future memory references

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Policy #3: Least Recently Used (LRU)

A

Idea:
approximates optimal by predicting that least recently used page is
one that won’t be used for longest time

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

“Locality”:

A

principle of program flow that says that consecutive memory references
tend to be close to each other (e.g.: code instructions, looping through
an array)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Policies #4+: Approximations of LRU

A

“4a. Reference Bits
• add “reference bit” column to page table
• initially, all bits set to 0
• reference to page p sets p’s reference bit to 1
• when all bits are 1, reset all to 0
• when replacing, choose any page with reference bit = 0”

“4b. Reference Bitstrings
• add n-bit column to page table
• initially, all bit strings = 00…0
• reference to page p sets rightmost bit of page p’s bit string to 1 e.g.: 01010010 ® 01010011
• after fixed amount of time, shift all bit strings to the left e.g.: 01010011 ® 10100110
® most assembly langs have “shift left”, “shift right” instructions for registers”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Policy #5: Least Frequently Used

A
  • also tries to approximate optimal.
  • predicts that page that will not be accessed for longest time in future is that which has been accessed the fewest time in past
  • requires maintaining counter for all pages in page table

”+: reasonable approximation of optimal in some cases
–: requires counter field in page table
requires write of memory for every memory reference likely to evict pages just brought into memory
• less compatible with locality compared to LRU”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Local Allocation

A

Idea:
• assign a process some number of frames when it is created
• page fault requires evicting a page that the process owns

ISSUE: Thrashing

• must provide minimum frame allocation to each process (as
determined by instruction set). Otherwise, thrashing is
inevitable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Local Allocation +

A

a. Equitable allocation: Each process gets ëm/nû frames
• Problem: Suppose P1 needs 10 frames, P2 needs 190 frames, 60
are available
• Both get 30 frames and P1 has 20 frames that it doesn’t need, and
that P2 does need
b. Proportional allocation
P2: (190/200) ´ 60 = 57 frames
P1: (10/200) ´ 60 = 3 frames
c. Priority-based allocation
e.g.: Give P1 all 10 frames if it has a higher priority than P2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Global Allocation

A

Idea: all processes have access to all frames
replacement: a process can replace page owned by another

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

The Working-Set Model

A

• based on locality – as process executes, it uses a different set of pages

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Working-Set Algorithm

A

Idea: Allocate enough frames to a process to fit the pages in its “current” locality

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Page-Fault Frequency Scheme

A

Idea: Monitor page-fault rate of every active process. React accordingly

  • if page fault rate > UB, allocate more frames
  • if page fault rate < LB, deallocate frames
  • may need to suspend process if cannot allocate more frames
  • increase degree of multi programming if surplus”
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Virtual memory

A

• permits logical address space > number of allocated frames
• permits higher degree of multiprogramming than pure paging
• performance concern: keep page fault frequency (r) low
à disk access :: memory access ~ 10,000 :: 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

page replacement

A

•essential tradeoff: low page fault frequency vs overhead to ensure

  1. per memory access (setting reference bits, time stamps…)
  2. periodic (SHL on reference bit strings)
  3. per page fault (scanning page table for page to evict)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly