0% found this document useful (0 votes)
29 views17 pages

Memory Management

Uploaded by

ramshakokab6
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views17 pages

Memory Management

Uploaded by

ramshakokab6
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 17

Memory Management

Policies
Key Design Policies
•Fetch Policy
Demand
Prepaging
•Replacement Policy
Optimal
Least Recently Used (LRU)
FIFO
Clock
Resident Set Management
Replacement Scope
2
Fetch Policy
• When a page should be brought into main
memory
1. Demand Paging
 A page is brought in memory only when referenced
 Initially a lot of Page faults would happen
 But it will settle down in a while
 Later page faults will drop to a very low level
2. Prepaging
 Pages other than the one demanded are brought
in memory
3
Replacement Policy
• Selection of a page in memory to be replaced
• When a new page must be brought in

4
Basic Replacement Algorithms
• Optimal
• Least Recently used
• FIFO

5
Optimal
• Select the page for which the time to the next
reference is the longest
• Just like SJF, very difficult to implement
• Assume a memory of 3 frames
• And 5 pages
• Let the reference sequence be
2 3 2 1 5 2 4 5 3 2 5 2

6
Pa
ge
Optimal Fa
F F F u lt
2 3 2 1 5 2 4 5 3 2 5 2

2
4
3
1
5
Select the page for which the time
to the next reference is the longest

7
Least Recently Used (LRU)
• Replace the page that has not been
referenced for the longest time
• Again, difficult to implement
• E.g.
 Tag each page with the time of last reference
 Should be updated on each instruction/data
reference.

8
Pa
ge
Least Recently Used (LRU) Fa
F F F F ult
2 3 2 1 5 2 4 5 3 2 5 2

2
3
3
5
1
4
2
Select the page Lest Recently Used

9
FIFO
• Treats the page frames as a circular buffer
• Removed in Round-Robin style
• 1. Simplest to implement
• 2. Replaces the page that has been in the
memory longest
• The assumption can be wrong
• Since, some region of code/data remain alive
throughout the programs

10
FIFO Pa
ge
F F F F F F F
2 3 2 1 5 2 4 5 3 2 5 2 au
lt

2
5
3
3
2
5
1
4
2

Replace the page that has


been in the memory longest
11
REPLACEMENT
ALGORITHM
• Optimal Replacement: replace the block which
is no longer needed in the future. If all blocks
currently in Memory will be used again,
replace the one which will not be used in the
future for the longest time.

• Random selection: replace a randomly


selected block among all blocks currently in
Memory.
• FIFO (first-in first-out): replace the block
that has been in Memory for the longest
time.
• LRU (Least recently used): replace the
block in Memory that has not been used
for the longest time.
• LFU (Least frequently used): replace the
block in Memory that has been used for
the least number of times.
First-In-First-Out (FIFO) Page
Replacement
FIFO Anomaly
Least-Recently-Used (LRU) Page Replacement
 The optimal replacement : the best but is not
realistic because when a block will be needed in the
future is usually not known ahead of time.

 The LRU is suboptimal based on the temporal


locality of reference, i.e., memory items that are
recently referenced are more likely to be referenced
soon than those which have not been referenced for
a longer time.

 FIFO is not necessarily consistent with LRU


therefore is usually not as good.

 The random selection, surprisingly, is not necessarily


bad.

You might also like