Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 24

CONTIGIOUS

MEMORY
ALLOCATION
Group 2
Shahala, Dilsha, Nivedh, Muhseen, Abhijeet
January 31st 2024
Introduction

Contiguous memory allocation is a classical memory allocation model


that assigns a process consecutive memory block (that is, memory blocks
having consecutive addresses). Contiguous memory allocation is one of
the oldest memory allocation schemes. The memory is usually divided
into two or more partitions and one of them is allocated to the resident
operating system and the rest for the user processes. It is possible to place
the operating system in either low memory or high memory. We assume
that the operating system is placed in low memory.

2
Single Contiguous Memory
In the scheme of single conti guous memory management, the physical
memory is conceptually divided into two conti guous areas. One of them
is permanently allocated to the resident porti on of the operati ng
system. The remaining memory is allocated to the transient and user
processes, which are loaded and executed one at a ti me, in response to
user commands Memory parti ti oning in single conti guous allocati on is
shown .This form of memory management is commonly used by single
process microcomputer operati ng systems, such as PC-DOS.

3
4 February 12, 2024
5

Protecting Operating System Code
1. Protection bit method :
Memory protection can be achieved by
2. Fence Register Method:
assigning a protection bit to each memory
word. Imagine dividing the memory into Involves a dedicated register defining the
two areas by setting protection bits in one boundary between OS and user areas. -
and clearing them in the other. During Detects and denies any attempt by user
system start-up, the operating system's processes to access OS code below the set
locations get protected. User programs run fence. - Modification of fence register must
in the remaining memory, restricted from be a privileged operation restricted
areas with set protection bits. This ensures from user processes.
the operating system and essential utilities
have unrestricted access for their
functions.

7
8
Advantages

1. Simplicity: The scheme is


straightforward, making it simple to
design.
2. Ease of Understanding: It doesn't
require extensive expertise to
comprehend or use. Disadvantages
1. Underutilization of Processor and Memory:
- Lack of support for multiprogramming reduces
processor and memory utilization.
- Processor cycles are wasted during I/O waits
without pending work.
- Memory is underutilized due to the portion not used
by the operating system or the active user.
2. Lack of Flexibility:
- User's job is limited to the available main memory
size, showing inflexibility in
9
accommodating larger tasks.
STATIC PARTITIONED MEMORY
MANAGEMENT
Contiguous partitioned allocation is one of the simplest memory
management techniques for supporting multiprogramming. In contiguous
partitioned allocation, main memory is divided into several partitions.
Each partition holds a separate process. Depending on and how partitions
are created and modified, memory partitioning may be static or dynamic.

In static (fixed) partitioned memory management scheme, the available physical memory
is logically divided into several partitions during system
generation process. These partitions could be of different sizes, but once
decided at the time of system generation, they cannot not be changed. The
number and size of individual partitions are usually determined during the
system generation process, taking into consideration the capacity of the
10
available physical memory,
Out of six partitions, one is
assumed to be occupied by the
resident portion
of the operating system, and
three others by user processes
P₁, Pj and Pk,
as indicated. The remaining two
partitions are free and available
for allocation.

11
Partition Partition Base Partition Size Partition Status
No
0 0K 100 K ALLOCATED
1 100 K 300 K FREE
2 400 K 100 K ALLOCATED
3 500 K 250 K ALLOCATED
4 750 K 150 K ALLOCATED
5 900 K 100 K FREE

As indicated each partition is described by its starting address (base),size and status. When
static partitioning is used, only the status field of each entry varies in the course of system
operation, depending on
whether the corresponding partition is allocated or not at any given instant. All other fields are
static and contain the values defined at partition definition time.
In the sample PDT given above, partitions 1 and 5 are assumed to be available for allocation
and partitions 0, 2, 3, and 4 are occupied by some processes.
When creating or activating a non-resident process,
the operating system checks the Process Descriptor
Table (PDT) to find a free memory partition. If
successful, the PDT entry is marked as
ALLOCATED, and the process image is loaded into
the partition. The PCB records the assigned partition.
Upon process termination or swapping, the PCB
information is used to find the related partition and
update its status to FREE in the PDT.
When allocating a free partition to a process, the operating
system can use either the first-fit or best-fit strategy. In the
first-fit strategy, the system allocates the first available
partition that is large enough for the process. In the best-fit
strategy, the smallest free partition
meeting the process requirements is allocated. The choice
between these strategies depends on factors such as
execution speed and memory utilization.
When allocating a free partition to a process, the operating
system can use either the first-fit or best-fit strategy. In the
first-fit strategy, the system allocates the first available
partition that is large enough for the process. In the best-fit
strategy, the smallest free partition
meeting the process requirements is allocated. The choice
between these strategies depends on factors such as
execution speed and memory utilization.
Processes waiting to be loaded in the
memory are held in queue by the
operating system. There are two
methods of maintaining this queue
multiple queue and single queue. In
multiple queue, there is one separate
queue for each When a process wants to occupy
partition, each corresponding to memory, it is added to a proper
queue depending upon the size of
different size of the partition.
the process. An advantage of this
scheme is that a very small process
is not loaded in a very large partition.
In the single queue method, only one
queue is maintained for all the ready
processes.
The memory manager may not be able to satisfy requests to
allocate memory partitions under certain situations. Some of them
are:
• No partition is large enough to accommodate the incoming
process.
• All partitions are allocated.
• Free but unsuitable partitions are available.

The job cannot be run if it is too large to fit into any of the system
partitions.
DYNAMIC PARTITIONED MEMORY
MANAGEMENT
Dynamic Partitioning is a memory
management technique used in
computing systems to allocate and Dynamic partitioning is a
deallocate memory resources as computer memory
needed. Unlike static partitioning, management technique that
dynamic partitioning allows for allows the system to allocate
and deallocate memory
the creation of new memory
resources as needed, creating
partitions or the resizing of
new partitions or resizing
existing ones at runtime. existing ones at runtime, in
order to optimize memory
Dynamic partitioning allows for efficient use of memory
resources by allocating memory only when needed and
utilization and improve
deallocating it when it is no longer needed. This helps system performance.
to optimize system performance and improve memory
utilization.
Explanation of Dynamic Partitioning Process

The process of dynamic partitioning involves the


following steps −
•The operating system maintains a table of all memory
partitions in the system, including their sizes and status
(allocated or free).
•When a process requires memory, the operating system
searches the table for a free partition of the required
size.
•If a free partition of the required size is found, the
operating system allocates the partition to the
requesting process.
•If no free partition of the required size is available, the
operating system may either split an existing larger
partition into two smaller ones, or create a new partition
of the required size.
•When a process no longer needs a memory partition,
the operating system deallocates the partition and
FRAGMENTATION

As processes are loaded and removed from memory, the free


memory space is broken in to 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 called fragmentation.
• Two types of fragmentations are
1. External fragmentation
2. Internal fragmentation
EXTERNAL
FRAGMENTATION

• External fragmentation is the


unused area between two used
areas. It is a serious problem.
Here memory space to satisfy a
request is available, but is not
contiguous.
EXTERNAL
FRAGMENTATION

• External fragmentation is the


unused area between two used
areas. It is a serious problem.
Here memory space to satisfy a
request is available, but is not
contiguous.
INTERNAL
FRAGMENTATION
• Consider the following figure.
Suppose a 25K request is coming,
then 30K is fully allocated because
it is a fixed partition. Here 5k is
wasted.
• That is the wasted space contained
in a partition that is allocated for a
request is called internal
fragmentation.
• It is a wasted space with in a
partition.
• Internal fragmentation can be
reduced effectively assigning the
smallest partition but large enough
for the process.
THANK YOU

You might also like