13_Operating Sytems-Memory Management
13_Operating Sytems-Memory Management
Computer Architecture
CT049-3-1-OS&CA
Ver: VE
Memory Management
Learning Outcomes
page 0 0 1 0
page 1 1 4 1 page 0
page 2 2 3 2
page 3 3 7 3 page 2
logical memory page table
4 page 1
7 page 3
physical memory
Secondary
Storage
4 5 6 7
8 9 10 11
Program B
12 13 14 15
Swap In
16 17 18 19
• What is Segmentation?
– Segmentation is a memory-management scheme that supports a user view of
memory.
– A logical address space is a collection of segments. Each segment has a name and
a length.
– The addresses specify both the segment name and the offset within the segment.
stack
segment 3 1400
Limit Base segment 0
0 1000 1400
symbol 2400
subroutine 1 400 6300
table 3200
2 400 4300
segment 0 segment 4
3 1100 3200 segment 3
4 1000 4700 4300
main segment 2
SQRT Segment table 4700
program
segment 4
segment 1 segment 2
5700
6300
Physical memory 6700 segment 1
Logical address space
Module Code & Module Title Slide Title SLIDE 11
Shared Segmentation
0
Limit Base
editor 43062
0 25286 43062
segment 0
1 4425 68348
editor
data 1 segment table process P1
segment 1 68348
data 1
72773
logical memory process P1
reference
1 2 trap
i backing
load M store
6 page table Free
restart
frame
instruction
5 4
reset bring in
page memory
table page
program physical
execution memory
Module Code & Module Title Slide Title SLIDE 16
Page Fault
frame valid-invalid
bit
swap
2
change to 1out
O i invalid victim
page O
F v 4
F victim
reset page
3 F
table for new
page swap
desired backing
page in store
page table
physical memory
Module Code & Module Title Slide Title SLIDE 22
Page Replacement
• Every operating system has its own unique page replacement algorithm.
• In selecting a particular algorithm we want the one with the lowest page
fault rate.
• Types of page replacement algorithms:-
– First In First Out
– Optimal
– Least Recently Used
reference string
7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1
7 7 7 2 2 2 2 4 4 4 0 0 0 0 0 0 0 7 7 7
0 0 0 0 3 3 3 2 2 2 2 2 1 1 1 1 1 0 0
1 1 1 1 0 0 0 3 3 3 3 3 2 2 2 2 2 1
16
14
12
number of page faults
10
8
0 1 2 3 4 5 6 7
number of frames
page-fault curve for FIFO replacement on a reference string
Module Code & Module Title Slide Title SLIDE 29
Optimal
reference string
7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1
7 7 7 2 2 2 2 2 2 2 2 2 2 2 2 2 2 7 7 7
0 0 0 0 0 0 4 4 4 0 0 0 0 0 0 0 0 0 0
1 1 1 3 3 3 3 3 3 3 3 1 1 1 1 1 1 1
Perform an Analysis of the Optimal Algorithm for the following string of memory
reference addresses. Assume that there are three frames available within the
memory for holding pages.
Module Code & Module Title Slide Title SLIDE 31
Least Recently Used
• Associates each page with time of when the page was last used.
• When a page needs to be replaced, the page that has not been used
the for the longest period will be chosen.
• Technique of looking backwards.
reference string
7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1
7 7 7 2 2 2 2 4 4 4 0 0 0 1 1 1 1 1 1 1
0 0 0 0 0 0 0 0 3 3 3 3 3 3 0 0 0 0 0
1 1 1 3 3 3 2 2 2 2 2 2 2 2 2 7 7 7
Perform an Analysis of the Least recently used for the following string of memory
reference addresses. Assume that there are three frames available within the
memory for holding pages.
Module Code & Module Title Slide Title SLIDE 33
Thrashing
degree of multiprogramming
Module Code & Module Title Slide Title SLIDE 35
Question
Q&A
Module Code & Module Title Slide Title SLIDE 39