Title: CSC 350 - Operating Systems
1CSC 350 - Operating Systems
2CSC 350 - Operating Systems
3CSC 350 - Operating Systems
4Memory Management I
II. Memory Management I
- manage the scarce resource of memory
5Memory Management I
C. Dynamic partitions MMS
- Partitions are created dynamically on the fly
6Memory Management I
Analogy
- Partitions are like suitcases
7Memory Management I
3. OS concept - allocation
- programs must be assigned to memory
- note if not enough contiguous RAM, program must
wait
8Memory Management I
- programs must be assigned to memory
- how? (tradeoffs)
9Memory Management I
a. first-fit
- the first (lowest) partition big enough for the
program will be allocated
10Memory Management I
a. first-fit
11Memory Management I
b. best-fit
- the best (causing least fragmentation) partition
will be allocated
12Memory Management I
b. best-fit
13Memory Management I
3. OS concept - allocation
14Memory Management I
3. OS concept - allocation
15Memory Management I
3. OS concept - allocation example problem 4,
p.39
- Job / Program size
- Block / Partition size
16Memory Management I
Memory map
Jobs programs on storage
block 1 block 2 block 3
610K
850K
J1 740K J2 500K J3 700K
700K
17Memory Management I
Memory map
a. best fit
block 1 block 2 block 3
J2 500K
610K
J1 740K
850K
J3 700K
700K
18Memory Management I
Memory map
b. first fit low - highsearch
block 1 block 2 block 3
J2 500K
610K
J1 740K
850K
J3 700K
700K
19Memory Management I
Memory map
b. first fit high-low search
block 1 block 2 block 3
610K
J1 740K
850K
J2 500K
700K
J3 700K wait
20Memory Management I
3. OS concept - allocation
- group exercise -)modified problem 4, p.39
21Memory Management I
- modified problem 4, p.39
- Job Size Block Size
- 1 740K 1 610K
- 2 500K 2 850K
- 3 600K 3 500K
22Memory Management I
3. OS concept - allocation
23Memory Management I
4. OS - deallocation
- programs must be removed from memory when
finished
24Memory Management I
4. OS - deallocation easy for fixed partitions
- more difficult for dynamic partitions
25Memory Management I
scenarios
- a. deallocated memory is not adjacent to free
memory
26Memory Management I
- a. deallocated memory is not adjacent to free
memory
allocated
To be deallocated
allocated
27Memory Management I
4. OS - deallocation
- scenarios
- b. deallocated memory is adjacent to one free
memory partition
28Memory Management I
- b. deallocated memory is adjacent to one free
memory
free
To be deallocated
allocated
29Memory Management I
4. OS - deallocation
- scenarios
- c. deallocated memory is between two free memory
partitions
30Memory Management I
- c. deallocated memory is between two free memory
blocks
free
To be deallocated
free
31Memory Management I
D. Relocatable Dynamic partitions MMS
- 1. Based upon Dynamic Partitions MMS with
additional feature
32Memory Management I
Based upon Dynamic Partitions MMS with additional
feature
- At times, OS will compact memory
33Memory Management I
Red allocated partitions Green free space
(unallocated RAM)
34Memory Management I
35Memory Management I
2. Tradeoffs
- a. advantages
- b. disadvantages
36Memory Management I
review CSAO sections 2.2 and 2.3
37Memory Management I
3. OS needs h/w assistance
- bounds register
- relocation register
38Memory Management I
B1 20K B2 10K B3 30K
Prog K Prog B Prog S
now, Program B terminates,
39Memory Management I
B1 20K B2 10K B3 30K
Prog K Prog S
now, Program B terminates, OS deallocates
Partition 2
40Memory Management I
B1 20K B2 30K
Prog K Prog S
now, Program B terminates, OS deallocates
Partition 2 and compacts (relocates)
41Memory Management I
B1 20K B2 30K
Prog K Prog S
Prog S Bounds Register 30K Relocation Register
-10K