Module 1
Module 1
Module 1
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.
The run-time mapping from virtual to physical addresses is done by a
hardware device Memory Management Unit(MMU). The physical address
always remains constant.
Contiguous Allocation
Single Partition
In the Contiguous Memory Allocation, each process is contained in a single contiguous
section of memory. In this memory allocation, all the available memory space remains
together in one place which implies that the freely available memory partitions are not
spread over here and there across the whole memory space.
Multiple Partition
The memory can be divided either in the fixed-sized partition or in the variable-sized
partition in order to allocate contiguous space to user processes.
Fixed-size Partition
This technique is also known as Static partitioning. In this scheme, the system
divides the memory into fixed-size partitions. The partitions may or may not be the
same size. The size of each partition is fixed as indicated by the name of the
technique and it cannot be changed.
In this partition scheme, each partition may contain exactly one process. There is a
problem that this technique will limit the degree of multiprogramming because the
number of partitions will basically decide the number of processes.
This technique is also known as Static partitioning. In this scheme, the system
divides the memory into fixed-size partitions. The partitions may or may not be the
same size. The size of each partition is fixed as indicated by the name of the
technique and it cannot be changed.
In this partition scheme, each partition may contain exactly one process. There is a
problem that this technique will limit the degree of multiprogramming because the
number of partitions will basically decide the number of processes.
Disadvantages
Internal Fragmentation
Suppose the size of the process is lesser than the size of the partition in that case
some size of the partition gets wasted and remains unused. This wastage inside the
memory is generally termed as Internal fragmentation
Variable-size
This scheme is also known as Dynamic partitioning. The size of the partition is not
declared initially. Whenever any process arrives, a partition of size equal to the size
of the process is created and then allocated to the process. Thus the size of each
partition is equal to the size of the process.
No Internal Fragmentation
As in this partition scheme space in the main memory is allocated strictly according
to the requirement of the process thus there is no chance of internal fragmentation.
Also, there will be no unused space left in the partition.
External Fragmentation
As there is no internal fragmentation which is an advantage of using this partition
scheme does not mean there will no external fragmentation. Let us understand this
with the help of an example: In the above diagram- process P1(3MB) and process
P3(8MB) completed their execution. Hence there are two spaces left i.e. 3MB and
8MB. Let’s there is a Process P4 of size 15 MB comes. But the empty space in
memory cannot be allocated as no spanning is allowed in contiguous allocation.
Because the rule says that process must be continuously present in the main
memory in order to get executed. Thus it results in External Fragmentation.
How to satisfy a request of size n from a list of free holes. There are some solutions
to this problem:
First Fit
In the First Fit, the first available free hole fulfil the requirement of the process
allocated.
Best Fit
In the Best Fit, allocate the smallest hole that is big enough to process requirements.
For this, we search the entire list, unless the list is ordered by size.
Worst Fit
In the Worst Fit, allocate the largest available hole to process. This method produces
the largest leftover hole.
non-contiguous memory
An operating system's non-contiguous memory allocation allows a process to get
several memory blocks in different locations throughout memory. The methods used
to make a process's physical address space non-contiguous are paging and
segmentation. Non-contiguous memory allocation divides the process into blocks
(or pages or segments), which are subsequently allotted to different memory
locations in accordance with the quantity of free memory.
Paging
Paging is a memory management scheme that eliminates the need for a contiguous
allocation of physical memory. The process of retrieving processes in the form of
pages from the secondary storage into the main memory is known as paging.
In paging, the physical memory is divided into fixed-size blocks called page frames,
which are the same size as the pages used by the process. The process’s logical
address space is also divided into fixed-size blocks called pages, which are the same
size as the page frames. When a process requests memory, the operating system
allocates one or more page frames to the process and maps the process’s logical
pages to the physical page frames.
The mapping between logical pages and physical page frames is maintained by the
page table, which is used by the memory management unit to translate logical
addresses into physical addresses. The page table maps each logical page number
to a physical page frame number.
It is a memory cache which is closer to the CPU and the time taken by CPU to access
TLB is lesser then that taken to access main memory.
Segmentation