0% found this document useful (0 votes)
3 views

lecture2osd

The document discusses memory management in operating systems, focusing on swapping and contiguous memory allocation techniques. It explains the process of swapping, its overhead, and the importance of memory allocation strategies like first-fit, best-fit, and worst-fit, along with the concepts of fragmentation. Additionally, it highlights the challenges of external and internal fragmentation and the need for compaction to reduce wasted memory space.

Uploaded by

skekramskekram3
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

lecture2osd

The document discusses memory management in operating systems, focusing on swapping and contiguous memory allocation techniques. It explains the process of swapping, its overhead, and the importance of memory allocation strategies like first-fit, best-fit, and worst-fit, along with the concepts of fragmentation. Additionally, it highlights the challenges of external and internal fragmentation and the need for compaction to reduce wasted memory space.

Uploaded by

skekramskekram3
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

OPERATING SYSTEMS

Memory Management

S.Thenmozhi
Department of Computer Applications
OPERATING SYSTEMS
Swapping

• A process can be swapped temporarily out of


memory to a backing store, and then brought back
into memory for continued execution
• Backing store – fast disk large enough to
accommodate copies of all memory images for all
users; must provide direct access to these memory
images
• Roll out, roll in – swapping variant used for
priority-based scheduling algorithms; lower-
priority process is swapped out so higher-priority
process can be loaded and executed
OPERATING SYSTEMS
Swapping
OPERATING SYSTEMS
Swapping
OPERATING SYSTEMS
Swapping

• Swapping is a slow process when compared to


other operations
• Swapping increases the overhead
• Hence it should be reduced as much as possible
• Swapping should be done only when the processes
are idle or don’t have any pending i/o operations
• Use only OS buffers during i/o operations, instead
of swapping
• Modern Oses (used in mobile phones) don’t use
swapping. It prompts the user to free up the
memory space
OPERATING SYSTEMS
Memory Allocation Techniques
OPERATING SYSTEMS
Contiguous Memory Allocation

• Main memory usually divided into two partitions:


• Resident operating system, usually held in low
memory with interrupt vector
• User processes then held in high memory
• Single partitioned contiguous memory allocation
• Entire memory is available for a single
application
• A small portion is left for the OS and rest is
used for user applications
• Example: MS-DOS
• Not much used in present day OSes
OPERATING SYSTEMS
Contiguous Memory Allocation

• Multiple partitioned contiguous memory allocation


• Divide all available memory into multiple
partitions
• Assign each process to a partition
• This can satisfy the requirement of multiple
programs accommodated in memory
• OS keep a information about the allocated
partitions and free partitions
• Unused memory block is called as holes
OPERATING SYSTEMS
Contiguous Memory Allocation
OPERATING SYSTEMS
Contiguous Memory Allocation

• When a process arrives, it is allocated memory from a hole


large enough to accommodate it
• OS may use different strategies to find a hole to fit the
process
• First-fit: Allocate the first hole that is big enough
• Best-fit: Allocate the smallest hole that is big enough;
must search entire list, unless ordered by size
• Worst-fit: Allocate the largest hole; must also search
entire list
• First-fit and best-fit better than worst-fit in terms of speed
and storage utilization
OPERATING SYSTEMS
Contiguous Memory Allocation
OPERATING SYSTEMS
Contiguous Memory Allocation

Fragmentation
• External Fragmentation – total memory space exists to
satisfy a request, but it is not contiguous
• Internal Fragmentation – allocated memory may be slightly
larger than requested memory; this size difference is
memory internal to a partition, but not being used
• Reduce external fragmentation by compaction
• Shuffle memory contents to place all free memory
together in one large block
• Compaction is possible only if relocation is dynamic, and
is done at execution time
• May lead to I/O problem
OPERATING SYSTEMS
Contiguous Memory Allocation
OPERATING SYSTEMS
Quiz

Suppose a process requests


12KB of memory and the
memory manager currently
has a list of unallocated
blocks of 6KB, 14KB, 19KB,
11KB, and 13KB blocks.
Where does the 12KB process
will get fitted using different
allocation strategies?
THANK YOU

S. Thenmozhi
Department of Computer Applications
[email protected]
+91 80 6666 3333 Extn 393

You might also like