You are on page 1of 21

Memory Management

Memory Management

 Contents:-
 Memory Management
 Contiguous and Non-Contiguous storage allocation
 Swapping
 Paging
 Segmentation
 Memory allocation method
 Logical vs physical address space
Cont....

Definition:-
Memory management is the process of controlling and coordinating
computer memory, assigning portions called blocks to various running programs
 to optimize overall system performance.
Purpose:-
In operating systems, memory management is the function
responsible for managing the computer's primary memory.  It determines how
memory is allocated among competing processes, deciding which gets memory,
when they receive it, and how much they are allowed.
Diagram:-

Contiguous Memory Allocation Versus Non Contiguous Memory Allocation

CONTIGUOUS MEMORY NONCONTIGUOUS MEMORY


 A memory allocation model that assigns  A memory allocation model that assigns a
memory blocks having consecutive addresses process to memory blocks located in different
to a process location
 Assigns consecutive blocks of memory to a  Assigns a process to memory blocks to
process location .it follows a non consecutive manner
 Overhead is minimum not much address  More overhead as there are more address
translations while executing a process translations.
 Easier for the operating system to control  Difficult to control
SWAPPING

 Definition:-
 Swapping is a mechanism in which a process can be swapped
temporarily out of main memory (or move) to secondary storage (disk) and make
that memory available to other processes. At some later time, the system swaps
back the process from the secondary storage to main memory.
 Though performance is usually affected by swapping process but it helps in
running multiple and big processes in parallel and that's the reason Swapping is
also known as a technique for memory compaction.
BENEFITS OF SWAPPING

 Some benefits of using swapping are as follows :


 It allow higher degree of multiprogramming .
 It allows dynamic relocation .it means that the process can be swapped
in difficult location if address binding is performed at execution time .
 It provides better memory utilization .
 It can be applied on priority based scheduling algorithms to improve
performance .
DIAGRAM
PAGING

 Definition :
 Paging is fixed size partitioning scheme .
 In paging secondary memory and main memory are divided inti equal
fixed size partition .
 The partition of secondary memory are called pages .
 The partitions of main memory are called as frames.
 Each process is divided into parts where size of each part is same as
page size.
EXAMPLE

 Consider a process is divided into 4 pages Pℴ,P1,P2 and P3


 Depending upon the availability these pages may be stored in the
main memory frames in a non contiguous fashion as shown –

P1

P3

P0

P2
BENEFITS OF PAGING

 Allocating memory is easy and cheap


 Any free page is ok ,OS can take first one out of list it keeps
 Elimination external fragmentation
 Page are mapped appropriately anyway
 No need for considerations about fragmentation
 Just swap out page least likely to be used
 More efficient swapping
DIAGRAM
WHAT IS SEGMENTATION

 Definition:
 Segmentation is a memory management technique which
supports user's view of memory. This technique of division of a
computer's primary memory into sections called segments.
TYPES OF SEGMENTATION

 Virtual memory segmentation


Each processor job is divided into several segments, It is not
essential all of which are resident at any one point in time.
 Simple segmentation
Each process is divided into many segments, and all segments are
loaded into the memory at run time, but not necessarily
contiguously
SEGMENT TABLE

 Definition :
the segment table contain information about the relationship
of the segments and regions in the program. During execution the
table also contains control information such as what segments are in
storage and which are being loaded.
DIAGRAM OF SEGMENTATION
MEMORY ALLOCATION METHOD

 Definition:-
Memory allocation is the process of setting aside
sections of memory in a program to be used to store variables, and
instances of structures and classes. When you declare a variable or
an instance of a structure or class. The memory for that object
is allocated by the operating system.
LOGICAL VS PHYSICAL ADDRESS
SPACE

LOGICAL ADDRESS PHYSICAL ADDRESS


 Logical address space is the set of all the  Physical address space is the set of all
logical address generated for a program physical addresses of a program
 Helps to obtain the physical address  Helps to identify a location in the main
memory
 Generates logical address
 Produced by the combination of the relocation
 An address at which an item such as memory
register and the logical address
cell storage element appears to reside from the
perspective of an executing program  A memory address that allow accessing a
particular storage cell in the main memory
TYPES OF MEMORY ALLOCATION

METHOD
Single-partition allocation
 In this type of allocation, relocation-register scheme is used to protect user
processes from each other, and from changing operating-system code and data.
Relocation register contains value of smallest physical address whereas limit
register contains range of logical addresses. Each logical address must be less
than the limit register.
 Multiple-partition allocation
 In this type of allocation, main memory is divided into a number of fixed-sized
partitions where each partition should contain only one process. When a
partition is free, a process is selected from the input queue and is loaded into the
free partition. When the process terminates, the partition becomes available for
another process.
FRAGMENTATION

DEFINITION:-
As processes are loaded and removed from memory, the free memory space is broken into
little pieces. It happens after sometimes that processes cannot be allocated to memory
blocks considering their small size and memory blocks remains unused. This problem is
known as Fragmentation.
FRAGMENTION is of two types :
 External fragmentation
 Total memory space is enough to satisfy a request or to reside a process in it, but it is
not contiguous, so it cannot be used.
 Internal fragmentation
 Memory block assigned to process is bigger. Some portion of memory is left unused, as
it cannot be used by another process.

You might also like