🔴 UNIT 2 – MEMORY MANAGEMENT
1️⃣ Memory Management – Introduction
✅ Definition
Memory management is the function of the OS that:
-
Allocates memory to processes
-
Deallocates memory after use
-
Manages primary and secondary memory efficiently
2️⃣ Memory Management Requirements
✔ Relocation
✔ Protection
✔ Sharing
✔ Logical organization
✔ Physical organization
3️⃣ Memory Management Techniques
🔹 1. Multiprogramming with Fixed Partitions
Concept:
-
Memory is divided into fixed-size partitions
-
One process per partition
Advantages:
✔ Simple
✔ Easy implementation
Disadvantages:
❌ Internal fragmentation
❌ Wastage of memory
🔹 2. Multiprogramming with Variable Partitions
Concept:
-
Memory allocated as per process size
-
No fixed partitions
Advantages:
✔ Less internal fragmentation
Disadvantages:
4️⃣ Memory Allocation Strategies
🔹 First Fit
Allocates first available memory block
✔ Fast
❌ Fragmentation
🔹 Best Fit
Allocates smallest possible block
✔ Less wastage
❌ Slow
🔹 Worst Fit
Allocates largest block
❌ Poor utilization
5️⃣ Swapping
Definition:
Process is temporarily moved from main memory to disk.
Purpose:
✔ Free memory
✔ Improve multiprogramming
6️⃣ Virtual Memory
Definition:
Virtual memory allows execution of processes even if:
-
Entire program is not in memory
Uses:
✔ Secondary memory
✔ Demand paging
7️⃣ Paging
Concept:
-
Memory divided into pages
-
Physical memory divided into frames
Address Format:
Advantages:
✔ No external fragmentation
✔ Easy memory management
Disadvantages:
❌ Internal fragmentation
8️⃣ Segmentation
Concept:
Memory divided based on logical units:
-
Code
-
Data
-
Stack
Address Format:
Advantages:
✔ Logical view
✔ Better protection
Disadvantages:
❌ External fragmentation
9️⃣ Paging vs Segmentation
| Paging | Segmentation |
|---|---|
| Fixed size | Variable size |
| No external fragmentation | External fragmentation |
| Hardware based | Logical view |
| Fast | Flexible |
🔟 Virtual Memory Techniques
🔹 Demand Paging
Pages loaded only when needed.
🔹 Page Fault
Occurs when required page is not in memory.
🔹 Page Replacement Algorithms
1. FIFO
Oldest page removed
2. LRU
Least recently used page removed
3. Optimal
Replaces page not used for longest time (best but impractical)
1️⃣1️⃣ Thrashing
Definition:
System spends more time paging than executing.
Causes:
-
High degree of multiprogramming
-
Insufficient memory
Prevention:
✔ Reduce multiprogramming
✔ Increase RAM
✔ Use good page replacement
📌 EXAM IMPORTANT QUESTIONS (UNIT 2)
✔ Explain paging and segmentation
✔ Difference between paging & segmentation
✔ Explain virtual memory
✔ Explain page replacement algorithms
✔ What is thrashing?
✔ Explain memory allocation strategies
No comments:
Post a Comment