Unit IV
Unit IV
21BTIS501-Operating System
Unit - IV
Memory Management
AY 2023-2024 SEM-I
Prof. (Dr) Dipti Patil
Mrs. Babeetta Bbhagat
1
MIT School of Computing
Department of Computer Science & Engineering
Unit-IV Syllabus
2
MIT School of Computing
Department of Computer Science & Engineering
PLD
7
MIT School of Computing
Department of Computer Science & Engineering
Advantages of Swapping
8
MIT School of Computing
Department of Computer Science & Engineering
Disadvantages of Swapping
• Performance Overhead
• Storage Overhead
• Data Integrity Issues
• Increased Disk Activity
9
MIT School of Computing
Department of Computer Science & Engineering
12
MIT School of Computing
Department of Computer Science & Engineering
13
MIT School of Computing
Department of Computer Science & Engineering
15
MIT School of Computing
Department of Computer Science & Engineering
17
MIT School of Computing
Department of Computer Science & Engineering
18
MIT School of Computing
Department of Computer Science & Engineering
Memory Allocation
• Memory allocation is a process by which
computer programs are assigned memory or
space.
• Here, main memory is divided into two types
of partitions
1. Low Memory – Operating system resides in
this type of memory.
2. High Memory– User processes are held in
high memory.
19
• Fixed Partitioning is also known as Contiguous
memory allocation. Fixed Partitioning is the easiest
method, which is used to load more than one process
into the main memory.
• In Fixed Partitioning, we divide the main memory into
partitions, and the size of partitions can be different or
equal. In the first partition, the operating system is
present, and the remaining partitions are used to store
the user processes. In a contiguous way, we allocate
the memory to the processes.
• In the fixed Partitioning:
1. There is no overlapping of partitions.
2. For the process execution, the process should be
present contiguously.
Disadvantages of Fixed Partitioning
Best Fit: It allocates the process to the partition that is the first smallest partition among the free
partitions.
Worst Fit: It allocates the process to the partition, which is the largest sufficient freely available partition
in the main memory.
Next Fit: It is mostly similar to the first Fit, but this Fit, searches for the first sufficient partition from the
last allocation point.
We have process p4 with 3kb
requirement
MIT School of Computing
Department of Computer Science & Engineering
Memory Allocation
• Memory allocation is a process by which
computer programs are assigned memory or
space.
• Here, main memory is divided into two types
of partitions
1. Low Memory – Operating system resides in
this type of memory.
2. High Memory– User processes are held in
high memory.
33
MIT School of Computing
Department of Computer Science & Engineering
Partition Allocation
• Memory is divided into different blocks or
partitions.
• Each process is allocated according to the
requirement.
• Partition allocation is an ideal method to
avoid internal fragmentation.
34
MIT School of Computing
Department of Computer Science & Engineering
Partition Allocation
• Below are the various partition allocation
schemes :
1. First Fit: In this type fit, the partition is
allocated, which is the first sufficient block
from the beginning of the main memory.
2. Best Fit: It allocates the process to the
partition that is the first smallest partition
among the free partitions.
35
MIT School of Computing
Department of Computer Science & Engineering
Partition Allocation
36
MIT School of Computing
Department of Computer Science & Engineering
37
MIT School of Computing
Department of Computer Science & Engineering
38
MIT School of Computing
Department of Computer Science & Engineering
39
MIT School of Computing
Department of Computer Science & Engineering
40
MIT School of Computing
Department of Computer Science & Engineering
42
MIT School of Computing
Department of Computer Science & Engineering
44
MIT School of Computing
Department of Computer Science & Engineering
45
MIT School of Computing
Department of Computer Science & Engineering
48
MIT School of Computing
Department of Computer Science & Engineering
52
MIT School of Computing
Department of Computer Science & Engineering
53
MIT School of Computing
Department of Computer Science & Engineering
54
MIT School of Computing
Department of Computer Science & Engineering
55
MIT School of Computing
Department of Computer Science & Engineering
57
MIT School of Computing
Department of Computer Science & Engineering
58
MIT School of Computing
Department of Computer Science & Engineering
59
MIT School of Computing
Department of Computer Science & Engineering
60
MIT School of Computing
Department of Computer Science & Engineering
61
MIT School of Computing
Department of Computer Science & Engineering
62
MIT School of Computing
Department of Computer Science & Engineering
63
MIT School of Computing
Department of Computer Science & Engineering
65
MIT School of Computing
Department of Computer Science & Engineering
68
MIT School of Computing
Department of Computer Science & Engineering
69
MIT School of Computing
Department of Computer Science & Engineering
Allocation of frames in OS
• The main memory of the system is divided into frames.
• The OS has to allocate a sufficient number of frames for
each process and to do so, the OS uses various algorithms.
• The five major ways to allocate frames are as follows:
1. Proportional frame allocation
2. Priority frame allocation
3. Global replacement allocation
4. Local replacement allocation
5. Equal frame allocation
70
MIT School of Computing
Department of Computer Science & Engineering
Allocation of frames in OS
71
MIT School of Computing
Department of Computer Science & Engineering
72
MIT School of Computing
Department of Computer Science & Engineering
73
MIT School of Computing
Department of Computer Science & Engineering
74
MIT School of Computing
Department of Computer Science & Engineering
75
MIT School of Computing
Department of Computer Science & Engineering
76
MIT School of Computing
Department of Computer Science & Engineering
What is Fragmentation?
• Processes are stored and removed from memory, which
creates free memory space, which are too small to use by
other processes.
• After sometimes, that processes not able to allocate to
memory blocks because its small size and memory blocks
always remain unused is called fragmentation.
• This type of problem happens during a dynamic memory
allocation system when free blocks are quite small, so it is
not able to fulfill any request.
77
MIT School of Computing
Department of Computer Science & Engineering
What is Fragmentation?
• Two types of Fragmentation methods are:
1. External fragmentation
External fragmentation can be reduced by rearranging
memory contents to place all free memory together in a
single block.
2. Internal fragmentation
The internal fragmentation can be reduced by assigning
the smallest partition, which is still good enough to
carry the entire process.
78
MIT School of Computing
Department of Computer Science & Engineering
80
MIT School of Computing
Department of Computer Science & Engineering
81
MIT School of Computing
Department of Computer Science & Engineering