UNIT IV Assignment
UNIT IV Assignment
✅ Advantages:
Simple to implement.
❌ Disadvantages:
✅ Advantages:
No internal fragmentation.
❌ Disadvantages:
3. Paging
✅ Advantages:
No external fragmentation.
❌ Disadvantages:
4. Segmentation
Memory is divided into variable-sized segments based on logical divisions (code, data,
stack).
✅ Advantages:
❌ Disadvantages:
Page replacement policies determine which page to replace when memory is full in virtual
memory systems.
Simple but can lead to Belady’s Anomaly (higher frames → more page faults).
Replaces the page that will not be used for the longest time.
Example:
LRU Simulation:
1 7 7-- ✅
2 0 70- ✅
3 1 701 ✅
4 2 012 ✅ (Replace 7)
6 3 123 ✅ (Replace 0)
7 4 234 ✅ (Replace 1)
Here are detailed answers for your Unit IV Operating System Assignment questions.
Working:
P1 0 29 30MB
P2 30 69 40MB
P3 70 89 20MB
✅ Advantages:
❌ Disadvantages:
Working:
o The process is divided into pages (in Paging) or segments (in Segmentation).
Example:
✅ Advantages:
❌ Disadvantages:
The Buddy Memory Allocation system is a dynamic memory allocation technique that:
1. Memory Initialization
o 64MB block is further split into 32MB + 32MB, until a sufficient block (64MB) is
found.
Example
✅ Advantages:
❌ Disadvantages:
Internal Fragmentation when process sizes are not exact multiples of power-of-2.
Complex implementation.
1. First Fit
The first available free block that fits the process is used.
Example:
✅ Fastest Algorithm
❌ Causes External Fragmentation
2. Best Fit
Example:
✅ Minimizes waste
❌ Slower than First Fit
3. Worst Fit
Example:
Non-Contiguous Memory
Feature Contiguous Memory Allocation
Allocation
block. blocks.
Memory
Wastes memory due to fragmentation. Uses memory efficiently.
Utilization
Logical Divides processes into pages Divides processes into segments (logical
Organization (fixed-size blocks). units like Code, Data, Stack).
Concept Explanation
Buddy System Allocates memory in power-of-2 sized blocks, splits & merges
Concept Explanation
memory dynamically.
First Fit Allocates first free block, fast but causes fragmentation.
3. Page Replacement
o If RAM is full, the OS replaces old pages using a page replacement algorithm
(LRU, FIFO, Optimal).
Memory Fragmentation
Memory fragmentation occurs when free memory is divided into small, non-contiguous
blocks, making it difficult to allocate memory to new processes.
Types of Fragmentation:
1. Internal Fragmentation
o Example: Allocating 4KB blocks for a 3.5KB process leaves 0.5KB unused.
2. External Fragmentation
o Example: A 10MB process cannot be allocated if RAM has 5MB free at two
different locations.
Memory Compaction
Example of Compaction
Before Compaction:
After Compaction:
✅ Efficient Memory Utilization – No fixed partitions, processes get exactly what they need.
✅ No Internal Fragmentation – Unlike fixed partitions, no wasted memory within allocated
space.
✅ More Flexibility – Allows different-sized processes to enter memory dynamically.
What is Segmentation?
Segmentation is a memory management technique that divides a program into logical
segments (Code, Data, Stack). Each segment has:
Advantages of Segmentation
✅ Logical Memory Division – Each segment represents a logical unit (e.g., functions, arrays,
stacks).
✅ Efficient Memory Usage – No internal fragmentation.
✅ Supports Dynamic Memory Growth – Segments can grow/shrink based on needs.
Disadvantages of Segmentation
Concept Explanation
Virtual Memory Uses secondary storage as an extension of RAM to run large programs.
Memory Internal: Wasted space inside allocated memory. External: Free memory
Fragmentation scattered in small blocks.
Memory Compaction Rearranges memory to merge free spaces and reduce fragmentation.