Unit 3-Memory Management
Unit 3-Memory Management
Answer:
First Fit: 212K is put in 500K partition, 417K is put in 600K
partition, 112K is put in 288K partition (new partition 288K =
500K - 212K), and 426K must wait.
Best Fit: 212K is put in 300K partition, 417K is put in 500K
partition, 112K is put in 200K partition and 426K is put in 600K
partition.
Worst Fit: 212K is put in 600K partition, 417K is put in 500K
partition, 112K is put in 388K partition and 426K must wait.
Key Idea: Replace the page that will not be used for
the longest period of time.
Each page can be labeled with the number of
instructions that will be executed before that page is
first referenced.
For example, for 3 page frames and 8 pages system,
the optimal page replacement would yield nine page
faults on our sample reference string as:
The Optimal Page Replacement Algorithm…
The first three reference causes faults that fill the
three empty frames.
The reference to page 2 replaces page 7, because 7
will not be used until reference 18, whereas page 0
will be used at 5, and page 1 at 14.
Similarly, the reference to page 3 replaces page 1, as
page 1 will be the last of the three pages in memory
to be referenced again and so on.
Advantage: It guarantees the lowest possible page
fault rate.
Disadvantage: Unrealizable because at the time of
the page fault, the OS has no way of knowing when
each of the pages will be referenced next. So this is
not used in practical system, however it can be used
to compare the performance of other page
replacement algorithms.
Prepared By: Lok Prakash Pandey 67
The First-In, First-Out (FIFO) Page Replacement Algorithm
Note: While tracing, provide time to each pages when they come ( starting
from 20 i.e. equal to length of reference string in this example)
Prepared By: Lok Prakash Pandey 68
The First-In, First-Out (FIFO) Page Replacement Algorithm…
Advantages:
Easy to understand and program.
Distributes fair chance to all.
Problems:
◦ FIFO is likely to replace heavily (or constantly)
used pages which are still needed for further
processing.
◦ Increased page fault rate (in above case 15).
Answer:
Number of frames LRU FIFO Optimal
1 20 20 20
2 18 18 15
3 15 16 11
4 10 14 8
5 8 10 7
6 7 10 7
7 7 7 7
Answer:
a. 219 + 430 = 649 (0 is segment number, 430 is offset and 649<819)
b. 2300 + 10 = 2310
c. illegal reference, trap to operating system
d. 1327 + 400 = 1727
e. illegal reference, trap to operating system