OS - Lect 5
OS - Lect 5
Lecture 5
Memory Management
• Swapping
• Segmentation
• Paging
Swapping
Swapping
• What happens if the main memory is full ?
• Memory swapping is a method wherein memory contents not
currently in use are swapped to a disk to make the memory
available for other applications or processes.
• Major part of swap time is transfer time; total transfer time is directly
proportional to the amount of memory swapped.
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.
Advantages of Memory Swapping
• More Memory
Memory swapping is a critical component of memory
management, enabling an operating system to handle requests
that would otherwise overwhelm a system.
• Continuous Operations
Swap file memory can be written to disk in a continuous manner,
enabling faster lookup times for operations.
• System Optimization
Application processes of lesser importance and demand can be
relegated to swap space, saving the higher performance physical
memory for higher value operations.
Context Switch Time including Swapping
The standard swapping not used in modern operating systems, we Swap only
when free memory extremely low
Contiguous Allocation
Contiguous Allocation
OS OS OS OS
process 9 process 9
process 8 process 10
Disadvantages of Compaction
• A huge amount of time is wasted in performing compaction.
• CPU sits idle for a long time.
• Not always easy to perform compaction.
In the following two topics (Paging and
segmentation) we talk about how the MMU
link between Logical addresses and physical
addresses
Paging
Paging
• Page offset (d) – combined with base address to define the physical
memory address that is sent to the memory unit.
4
1
3 2
4
• Protection bits
associated with
segments; code sharing
occurs at segment level