Unit 3
Unit 3
Memory
handles or manages and every memory
primary memory and location, regardless of
moves processes back either it is allocated to
and forth between main
management
some process or it is
memory and disk free.
during execution.
03 04
It checks how much
It tracks whenever
memory is to be
some memory gets
allocated to processes.
freed or unallocated
It decides which
and correspondingly it
process will get
updates the status.
memory at what time.
Static Loading
• In static loading, Initially, the complete program is loaded into the
main memory before execution.
• In the case of static loading, the entire program is compiled and
linked, leaving no program or external module dependencies at
compile time.
• Static Loading is very useful when the program isn’t too big or
complicated, and when you plan to use the program multiple times.
• Example – Static loading is only done in the case of structured
programming languages like C.
Dynamic loading
• So the Dynamic loading, the compiler, the program, and for any
module that needs to be included dynamically, that provided only as a
reference to them, and the rest of the work will be done at runtime.
And the complete program and all process data must be in physical
memory for the process to run.
A. First Fit
B. Best Fit
C. Worst Fit
1. First Fit:
• In the first fit, the partition is
allocated which is the first
sufficient block from the top of
Main Memory. It scans memory
from the beginning and chooses
the first available block that is
large enough. Thus it allocates
the first hole that is large
enough.
2. Best Fit
• 2. Best Fit Allocate the process
to the partition which is the first
smallest sufficient partition
among the free available
partition. It searches the entire
list of holes to find the smallest
hole whose size is greater than
or equal to the size of the
process.
3. Worst Fit
• 3. Worst Fit Allocate the process
to the partition which is the
largest sufficient among the
freely available partitions
available in the main memory. It
is opposite to the best-fit
algorithm. It searches the entire
list of holes to find the largest
hole and allocate it to process.
Paging
• Paging is a method used by
operating systems to manage
memory efficiently.
• It breaks physical memory into
fixed-size blocks called “frames”
and logical memory into blocks
of the same size called “pages.”
• When a program runs, its pages
are loaded into any available
frames in the physical memory.
Paging protection
• The paging process should be protected by using the concept of
insertion of an additional bit called Valid/Invalid bit.
• This bit is used to indicate whether a page is currently in memory or
not.
• If the bit is set to valid, the page is in memory, and if it is set to
invalid, the page is not in memory.
Advantage and disadvantage
• Paging in operating systems offers streamlined memory management
but presents challenges like internal fragmentation and the overhead
of managing page tables.
Segmentation
• The segmentation technology is used in operating systems and the
process is divided into many pieces called segments and these
segments are of variable size.
• In this, segmentation uses a variable partitioning method: one
segment is equal to one complete memory block.
• The access and details of each segment, they are stored in a
segment table consisting of two fields.
There are two types of information
stored in segment table:
• Limit
• Base
Limit:The limit is the length or size of the segment
Base:The base is the base address of the segment
Types of segmentation
• Virtual Memory Segmentation: Each process is divided into a number
of segments, but the segmentation is not done all at once. This
segmentation may or may not take place at the run time of the
program.
• Simple Segmentation: Each process is divided into a number of
segments, all of which are loaded into memory at run time, though
not necessarily contiguously.
Advantages and Disadvantages
• Internal fragmentation is • External fragmentation may
avoided occur
• Less overhead • Expensive
• Segment table size is less than • Tough to allocate memory in
the page table size contiguous manner to variable
• Relocation of segment is easier size partition
Segmentation with paging
• A memory management technique known as Segmentation with
Paging in OS combines the benefits of both segmentation and paging.
• The main memory is split into variable-size segments, which are
subsequently partitioned into segmentation with paging in os"smaller
fixed-size disk pages
Advantages of segmented paging
• Reduces memory usage
• Page table size is limited by segment size
• External fragmentation is not there
• Simplifies memory allocation
Disadvantages of segmented paging
• Internal fragmentation is there
• Complexity level is higher
• Page tables should be stored contiguously in memory