Professional Documents
Culture Documents
inspire posterity
CHAPTER 4
Memory Management Issues
Lecture 23
22/10/2019 1
discover yourself
inspire posterity
EXAMPLE-1
OPTIMAL ALGORITHM
discover yourself
inspire posterity
The first three references cause 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.
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.
With only nine page faults, optimal replacement is much better than a FIFO
algorithm, which resulted in fifteen faults.
discover yourself
inspire posterity
EXAMPLE-2
OPTIMAL ALGORITHM
discover yourself
inspire posterity
EXAMPLE-3
Apply OPTIMAL ALGORITHM
No. of Frames = 3
0 2 4 6 2 0 9 5 3 8 1 7 1 7
discover yourself
inspire posterity
EXAMPLE-3 SOLUTION
Apply OPTIMAL ALGO
No. of Frames = 3
0 2 4 6 2 0 9 5 3 8 1 7 1 7
0 0 0 0 0 0 9 9 9 8 8 8 8 8
2 2 2 2 2 2 5 5 5 1 1 1 1
4 6 6 6 6 6 3 3 3 7 7 7
discover yourself
inspire posterity
EXERCISE-1
Apply OPTIMAL Algorithm
discover yourself
inspire posterity
EXPLANATION
Notice that the first 5 faults are the same as those for optimal
replacement.
When the reference to page 4 occurs, however, LRU replacement sees
that, of the three frames in memory, page 2 was used least recently.
Thus, the LRU algorithm replaces page 2, not knowing that page 2 is
about to be used.
When it then faults for page 2, the LRU algorithm replaces page 3, since it
is now the least recently used of the three pages in memory.
Despite these problems, LRU replacement with 12 faults is much better than
FIFO replacement with 15.
discover yourself
inspire posterity
SOLUTION of Example-2
discover yourself
inspire posterity
Frank - P. Weisberg
discover yourself
inspire posterity
10/22/201
9 17
discover yourself
inspire posterity
3 7 6 4 6 2 1 9 2 8
10/22/201
9 18
discover yourself
inspire posterity
SOLUTION OF EXAMPLE-1
10/22/201
9 19
discover yourself
inspire posterity
701203042303212
10/22/201
9 20
discover yourself
inspire posterity
SOLUTION OF EXAMPLE-2
10/22/201
9 21
discover yourself
inspire posterity
10/22/2019 22
discover yourself
inspire posterity
PAGING Segmentation
1. Main memory is divided into small fixed- 1. Main memory not partitioned
size chunks called frames. 2. Program is broken down into segments
2. Program is broken down into small specified by programmer to the
chunks called pages, handled by memory compiler.
management or compiler. 3. external fragmentation.
3. no external fragmentation. 4. OS must maintain a segment table for
4. OS must maintain a page table for each each process showing which frame each
process showing which frame each process occupy.
process occupy. 5. OS must maintain a free frame list.
5. OS must maintain a free frame list. 6. All the pages of a process must be in
6. All the pages of a process must be in main memory for process to run.
main memory for process to run.
10/22/2019 23
discover yourself
inspire posterity
End of Chapter-4