Lecture 12 Memory Mangement Week14
Lecture 12 Memory Mangement Week14
MANAGEMENT IN
OPERATING SYSTEM
CHAPTER 8: MAIN MEMORY
MEMORY MANAGEMENT IN OS
• Memory management is the process of intelligently handling all the memory related
operations and resources in the primary memory or storage disk when there are multiple
processes that are using memory and resources. It keeps track of all the memory, it may be
idle in the system or can be allocated to different processes at a given time.
• Internal 7. Thrashing
• External 8. Translation lookaside buffer
PARTITION ALLOCATION METHOD
• The memory systems developed in early 1990 had a contiguous(continuous) memory
available for storing different files one example of such traditional OSes is MS-Dos.
• But, new systems that have been developed do not have a contiguous memory space
available for files. In fact they are divided into blocks of different sizes.
• This was done to avoid complete memory
corruption if a file is infected. If memory is
divided into blocks corrupted file will only
infect that memory block in which its stored.
PARTITION ALLOCATION METHOD
• Example of Memory Partitioning
• For example, a 500Mb memory may be (equally or unequally) divided to blocks 5 blocks of 100Mb each.
• Or unequally as in 5 blocks of 125mb, 75mb, 125mb, 75mb, 125mb respectively.
• The main memory must accommodate –
1. Operating system
2. User processes
3. Operating System Processes
• For a partitioned memory available in modern systems, we need different algorithms to decide most which
processes must use which memory block while maintaining the most efficient use of these memory block.
• We therefore need to allocate different parts of the main memory in the most efficient way possible
PARTITION ALLOCATION METHOD
• Static Partitioning-
Static partitioning is a fixed size partitioning scheme.
In this technique, main memory is pre-divided into fixed size partitions.
The size of each partition is fixed and can not be changed.
Each partition is allowed to store only one process.
• Example-
Under fixed size partitioning scheme, a memory of size 10 KB may be divided into
fixed size partitions as-
These partitions are allocated to the processes as they arrive.
The partition allocated to the arrived process depends on the algorithm followed
MEMORY MANAGEMENT IN OS
MEMORY MANAGEMENT IN OS
• There are two major divisions one for operating system residing and other for allocating processes.
• OS memory can’t be altered in a direct by way by user.
• Process memory is managed by OS to perform processes.
• Job 3 (size 35 K)
• Can fit Block 1 but block 1 is not
• mpty(used by job2)
• Can’t fit and also Block 2 not empty
• Can fit in block 3 Goes to block 3
• Job 4
• Goes to block 4
• Job 5
• All blocks 1 to 4 are occupied
• Can’t fit in block 5 as size is more than
block
• So block 5 remains unused. and Job5 has
to wait until other processes finish.
FIRST FIT
Facts:
First-fit memory allocation is faster in making allocation but leads to memory waste.
If the chosen block is significantly larger than that requested, then it is usually split, and the
remainder added to the list as another free block.
The first fit algorithm performs reasonably well, as it ensures that allocations are quick.
When recycling free blocks, there is a choice as to where to add the blocks to the free list—
effectively in what order the free list is kept.
BEST FIT
• Example
• Job 1 (size – 100k)
• Block 1 size(50k) – 100k = Negative value
• Block 2 size(200k) – 100k = 100k
• Block 3 size(70k) – 100k = Negative value
• Block 4 size(115k) – 100k = 15k
• Block 5 size(15k) – 100k = Negative value
• Goes to block 4 as 15K is best case
BEST FIT
• Job 5(23k)
• Last job entered in block 5 and there no further blocks, so goes back to block 1
• Goes to block 1 as block size(50k) > job size(23k).
Any Question?