You are on page 1of 16

Operating System

(PCC-CS403)

Introduction to Memory Management


By
Prof. Prasenjit Kumar Das
Dept. of CST/CSIT, UEM Kolkata
Email : prasenjitdas139@gmail.com
Module 8: Memory Management: background, logical vs. physical address space, swapping, contiguous memory allocation,
paging, segmentation, segmentation with paging.
Module 9: Virtual Memory: background, demand paging, performance, page replacement, page replacement algorithms
(FCFS, LRU), allocation of frames, thrashing.
Module 10: File Systems: file concept, access methods, directory structure, file system structure, allocation methods
(contiguous, linked, indexed), free-space management (bit vector, linked list, grouping), directory
implementation (linear list, hash table), efficiency & performance.
Module 11: I/O Management: I/O hardware, polling, interrupts, DMA, application I/O interface (block and character devices,
network devices, clocks and timers, blocking and non-blocking I/O), kernel I/O subsystem(scheduling, buffering,
caching, spooling and device reservation, error handling), performance.
Module 12: Disk Management, disk structure, disk scheduling (FCFS, SSTF, SCAN,C-SCAN) , disk reliability, disk
formatting, boot block, bad blocks.
Module 13: Goals of protection, domain of protection, security problem, authentication, one time password, program threats,
system threats, threat monitoring, encryption.

Text Books:
1. Milenkovie M., “Operating System: Concept & Design”, McGraHill.
2. Tanenbaum A.S., “Operating System Design & Implementation”, Practice Hall NJ.
3. Silbersehatz A. and Peterson J.L., “Operating System Concepts”, Wiley.
4. Dhamdhere: Operating System TMH
5. Stalling, William, “Operating Systems”, Maxwell Mc Millan International Editions,1992.
6. DietelH. N.,“An Introduction to Operating Systems”, Addison Wesley
Contiguous Memory Allocation
Memory Allocation
For effective memory utilization, allocation of memory must be done in an
efficient manner.

 One of the simplest methods for allocating memory is to divide memory into
several fixed-sized partitions and each partition contains exactly one process.

Thus, the degree of multiprogramming is obtained by the number of partitions.

Multiple partition allocation: In this method, a process is selected from the


input queue and loaded into the free partition. When the process terminates, the
partition becomes available for other processes. 
Memory Allocation (Cont.)
Fixed partition allocation: In this method, the operating system maintains a table that
indicates which parts of memory are available and which are occupied by processes.

Initially, all memory is available for user processes and is considered one large
block of available memory. This available memory is known as “Hole”. When the
process arrives and needs memory, it search for a hole that is large enough to store
this process. 

 If the requirement fulfills then it allocate memory to process, otherwise keeping the
rest available to satisfy future requests.
Memory Allocation (Cont.)
 Sometimes while allocating a memory dynamically, there can be certain problems
which concerns how to satisfy a request of size n from a list of free holes.
 And to address such problems there are certain solutions as discussed below:
First Fit : The first available free hole fulfills the requirement of the process
allocated in first fit.
Best fit:- In the best fit, it allocate the smallest hole that is big enough to
process requirements. For this, search the entire list, unless the list is ordered by
size.  In this method memory utilization is maximum as compared to other memory
allocation techniques.
Worst fit:-In the worst fit, allocate the largest available hole to process. This
method produces the largest leftover hole. Inefficient memory utilization is a major
issue in the worst fit.
Fragmentation:

 Fragmentation is an unwanted problem where the memory blocks cannot be


allocated to the processes due to their small size and the blocks remain unused.

 It can also be understood as when the processes are loaded and removed from
the memory they create free space or hole in the memory and these small blocks
cannot be allocated to new upcoming processes and results in inefficient use of
memory.
Internal Fragmentation
In this fragmentation, the process is allocated a memory block of size more than
the size of that process. Due to this some part of the memory is left unused and
this cause internal fragmentation.
 For ex: Suppose there is fixed partitioning (i.e. the memory blocks are of fixed
sizes) is used for memory allocation in RAM. These sizes are 2MB, 4MB, 4MB,
8MB.
 Now, suppose a process P1 of size 3MB comes and it gets memory block of size
4MB. So, the 1MB that is free in this block is wasted and this space can’t be
utilized for allocating memory to some other process. This is called internal
fragmentation.
Internal Fragmentation cont..
How to overcome the problem of Internal Fragmentation????

This problem is occurring because we have fixed the sizes of the


memory blocks. This problem can be removed if we use dynamic
partitioning for allocating space to the process.

In dynamic partitioning, the process is allocated only that much


amount of space which is required by the process. So, there is no
internal fragmentation.
External Fragmentation
In this fragmentation, although we have total space available that is needed by a
process still we are not able to put that process in the memory because that space
is not contiguous. This is called external fragmentation.

 For Ex: Suppose in the above example, if three new processes P2, P3, and P4
come of sizes 2MB, 3MB, and 6MB respectively. Now, these processes get
memory blocks of size 2MB, 4MB and 8MB respectively allocated.

 So, now if we closely analyze this situation then process P3 (unused 1MB)and
P4(unused 2MB) are again causing internal fragmentation. So, a total of 4MB
(1MB (due to process P1) + 1MB (due to process P3) + 2MB (due to process P4))
is unused due to internal fragmentation.
 Now, suppose a new process of 4 MB comes. Though we have a total space of
4MB still we can’t allocate this memory to the process. This is called external
fragmentation.
How to overcome the problem of External Fragmentation????

 This problem is occurring because we are allocating memory continuously to


the processes. So, if we remove this condition external fragmentation can be
reduced. This is what done in paging & segmentation(non-contiguous memory
allocation techniques) where memory is allocated non-contiguously to the
processes.

Another way to remove external fragmentation is compaction. When dynamic


partitioning is used for memory allocation then external fragmentation can be
reduced by merging all the free memory together in one large block. This
technique is also called defragmentation. This larger block of memory is then used
for allocating space according to the needs of the new processes.
Attendance!!

You might also like