Chapter-V Memory Management
Chapter-V Memory Management
OSY - 22516
UNIT-V
MEMORY MANAGEMENT
• It also focus on
– Upgrading the performance of computer system
– Availability
– Consistency
1. Process Isolation
– Demand paging
– Demand segmentation
Fig: Virtual Memory That is Larger Than Physical Memory
Fig: Virtual Address Space
Fig: Shared Library using Virtual Memory
VIRTUAL MEMORY
• PAGING
– Faster response
– More users
• (1 → in-memory, 0 → not-in-memory)
• The paging hardware, in translating the address through the page table,
will notice that the invalid bit is set, causing a trap to the operating
system.
• This trap is result of the operating system’s failure to bring the desired
page into memory
VIRTUAL MEMORY
• What happens if the process tries to access a page that was not brought
into memory?
• The paging hardware, in translating the address through the page table,
will notice that the invalid bit is set, causing a trap to the operating
system.
• This trap is result of the operating system’s failure to bring the desired
page into memory
VIRTUAL MEMORY
• The procedure for handling this page fault is as follows.
1. Check an internal table for the process to determine whether the reference was a
valid or an invalid memory access.
2. If the reference was invalid, terminate the process. If it was valid, but page is not
yet brought, the get the page in memory.
4. Schedule a disk operation to read the desired page into newly allocated frame.
5. When the disk read is complete, modify the internal table kept with the process
& the page table to indicate that the page is now in memory.
6. We restart the instructions that was interrupted by the trap. The process can now
access the page as though it had always been in memory
PAGE REPLACEMENT ALGORITHM
• These algorithms are developed to reduce PAGE FAULT
problem.
• For bringing the required page into main memory, if the space
is not available in memory then we need to remove the page
from the main memory for allocating the space to the new
page which needs to be executed.
• 3. Read the desired page into the (newly) free frame. Update
the page and frame tables.
• Reference string: 1, 2, 3, 4, 2, 5, 3, 4, 2, 6, 7, 8, 7, 9, 7, 8, 2, 5,
4, 9.
• PAGE FAULT : 14
RS 1 2 3 4 2 5 3 4 2 6 7 8 7 9 7 8 2 5 4 9
1 1 1 1 4 4 4 6 6 6 9 9 9 4 4
2 2 2 2 5 5 5 7 7 7 2 2 2 2
3 3 3 3 2 2 2 8 8 8 5 5 9
PF PF PF PF PF PF PF PF PF PF PF PF PF PF PF
• Reference string: 1, 2, 3, 4, 2, 5, 3, 4, 2, 6, 7, 8, 7, 9, 7, 8, 2, 5,
4, 9.
• PAGE FAULT : 12
RS 1 2 3 4 2 5 3 4 2 6 7 8 7 9 7 8 2 5 4 9
1 1 1 1 1 5 5 5 5 9 9 9 9
2 2 2 2 2 6 6 6 6 2 2 2
3 3 3 3 3 7 7 7 7 5 5
4 4 4 4 4 8 8 8 8 4
PF PF PF PF PF PF PF PF PF PF PF PF PF
PAGE REPLACEMENT ALGORITHM
• LEAST RECENTLY USED (LRU) ALGORITHM
• LRU uses the TIME of the page that was last used.
• A. COUNTER
• B. STACK
PAGE REPLACEMENT ALGORITHM
• A. COUNTERS
• By this, the most recently used page is on the top & least used
page is at bottom.
• PAGE FAULT : 16
RS 1 2 3 4 2 5 3 4 2 6 7 8 7 9 7 8 2 5 4 9
1 1 1 1 4 4 3 3 3 6 6 6 9 2 2 2 9
2 2 2 2 2 2 4 4 4 7 7 7 7 5 5 5
3 3 3 5 5 5 2 2 2 8 8 8 8 4 4
PF PF PF PF PF PF PF PF PF PF PF PF PF PF PF PF PF
• Reference string: 1, 2, 3, 4, 2, 5, 3, 4, 2, 6, 7, 8, 7, 9, 7, 8, 2, 5,
4, 9.
• PAGE FAULT : 13
RS 1 2 3 4 2 5 3 4 2 6 7 8 7 9 7 8 2 5 4 9
1 1 1 1 1 5 6 6 6 6 2 2 2 2
2 2 2 2 2 2 2 2 9 9 5 5 5
3 3 3 3 3 7 7 7 7 7 4 4
4 4 4 4 8 8 8 8 8 9
PF PF PF PF PF PF PF PF PF PF PF PF PF PF
PAGE REPLACEMENT ALGORITHM
• OPTIMAL PAGE REPLACEMENT ALGORITHM (OPT)
• Replace page that will not be used for longest period of time
• PAGE FAULT : 13
RS 1 2 3 4 2 5 3 4 2 6 7 8 7 9 7 8 2 5 4 9
1 1 1 1 4 4 4 6 7 7 7 2 2 4
2 2 2 2 5 5 5 5 8 8 8 5 5
3 3 3 3 2 2 2 2 9 9 9 9
PF PF PF PF PF PF PF PF PF PF PF PF PF PF
• Reference string: 1, 2, 3, 4, 2, 5, 3, 4, 2, 6, 7, 8, 7, 9, 7, 8, 2, 5,
4, 9.
• PAGE FAULT : 11
RS 1 2 3 4 2 5 3 4 2 6 7 8 7 9 7 8 2 5 4 9
1 1 1 1 1 5 5 5 5 9 9 9
2 2 2 2 2 2 2 2 2 5 5
3 3 3 3 6 7 7 7 7 4
4 4 4 4 8 8 8 8
PF PF PF PF PF PF PF PF PF PF PF PF