0% found this document useful (0 votes)
30 views18 pages

Memory Management

Operating system
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views18 pages

Memory Management

Operating system
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 18

Memory

Management
Memory Management
Module of Operating System

The task of subdividing the memory among different processes is


called Memory Management.
Memory management is a method in the operating system to
manage operations between main memory and disk during process
execution.
Main Memory
Main memory is also known as RAM (Random Access Memory).
This memory is volatile. RAM loses its data when a power
interruption occurs.
Main memory is the place where programs and information are
kept when the processor is effectively utilizing them.
Main memory is associated with the processor, so moving
instructions and information into and out of the processor is
extremely fast.
Functions of Memory Management

1. Memory Allocation
2. Memory deallocation
3. Memory protection

How the protection is provided?


Goals of Memory Management

1. Maximum utilization of space, minimum


wastage(minimum memory fragmentation)
2. Ability to run larger program with limited space
 Virtual memory concept
Logical and Physical Address Space

1. Logical Address Space:

An address generated by the CPU is known as a “Logical


Address”.
It is also known as a Virtual address.
Logical address space can be defined as the size of the process.
A logical address can be changed.
Logical and Physical Address Space

2. Physical Address Space:

An address seen by the memory unit (i.e. the one loaded into the
memory address register of the memory) is commonly known as
a “Physical Address”.
 A Physical address is also known as a Real address.
The set of all physical addresses corresponding to these logical
addresses is known as Physical address space.
A physical address is computed by MMU.
Static and Dynamic Loading

Loading is a process into the main memory is done by a loader.


There are two different types of loading:
1. Static loading
2. Dynamic loading
Static Loading: Static Loading is basically loading the entire
program into a fixed address. It requires more memory space.
Dynamic loading: Dynamic loading delays loading a routine into
memory until it is called, allowing programs to execute without
requiring all data in memory at once. This improves memory
utilization by loading only necessary routines, keeping unused
ones on disk.
Static and Dynamic Linking

To perform a linking task a linker is used. A linker is a program


that takes one or more object files generated by a compiler and
combines them into a single executable file.
1. Static linking
2. Dynamic linking
Memory Management Techniques

Memory management techniques are methods used by an


operating system to efficiently allocate, utilize, and manage
memory resources for processes. These techniques ensure smooth
execution of programs and optimal use of system memory
1. Contiguous
2. Non-contiguous
Memory Management Techniques

Contiguous:
Entire process should be stored in main memory on consecutive
locations.
1. Fixed partition
2. Variable partition
Memory Management Techniques

Non-Contiguous:
Entire process can be stored in main memory on non-consecutive
locations.
1. Paging
2. Segmentation
Fixed Partition Contiguous MMT

The main memory is divided into fixed number of partition and


each partition can be used to accommodate maximum one
process.
Maximum number of processes is limited by number of partition.

OS
1040
P1 .
1045
1046
p2 .
1050
.
p3 .
.
.
.
p4 1100
Partition Allocation policy

A new process arrives ,with size 50KB


OS
50KB
P1
Partition Allocation Policy Allocated partition
p2 200KB

1. First fit 150KB


2. Best fit 60KB p3 100KB

3. Worst fit 200KB


60KB
4. Next fit 100KB if 200KB partition was p4
last allocated
Partition Allocation policy

Problem:
Whichever policy is used , there is an internal fragmentation.
If the extra space is allocated to process more than required
space.
Hence the wastage of that extra space is known as internal
fragmentation
Variable Partition contiguous MMT

Main memory is not divided into partition initially.


When a new process arrives, a new partition is created of
same size as process size, and the process is allocated into
that partition.
Hence no any internal fragmentation.
Variable Partition contiguous MMT

We have total main memory size is 600KB.


New process p1 arrives with size 150KB.
New process p2 arrives with size 100KB.
New process p3 arrives with size 200KB.
P2 is completed and terminate.
Now p4 arrives with size 200KB
But p4 is not allocated because 200KB space is not available
consecutively. This is called external fragmentation.
Variable Partition contiguous MMT

If enough space is available to store a process but not


consecutive hence wastages of space is known as external
fragmentation.
Problem: External fragmentation
Solution: Compaction
Compaction: collect entire allocated processes into one
side of memory, so that other side of memory can have
entire free space.

You might also like