Memory and Resource Management in
Modern Operating Systems
1. Virtual Memory
Virtual memory is a memory management technique that provides an abstraction of a large,
uniform memory space to processes, regardless of the actual physical memory size.
• Allows processes to use more memory than physically available.
• Provides process isolation and security.
• Implemented using paging and segmentation.
Diagram:
[Process Virtual Address Space] → [Virtual Memory Manager] → [Physical Memory + Disk]
2. Demand Paging
Demand paging is a technique where a page is loaded into memory only when it is required
during execution.
• Reduces initial load time.
• Page fault occurs when the requested page is not in memory.
• Requires page replacement policies to handle memory full conditions.
Diagram:
[Process Request] → [Page Table Check] → (If page not present → Page Fault → Load from
Disk)
3. Page Replacement Policies
When physical memory is full, page replacement policies decide which page to evict:
• FIFO (First-In-First-Out): Replaces the oldest page.
• LRU (Least Recently Used): Replaces the least recently accessed page.
• Optimal: Replaces the page that will not be used for the longest future duration.
• Random: Selects a random page for replacement.
4. Huge Pages
• Huge pages are memory pages significantly larger than standard (e.g., 2MB or 1GB vs.
4KB).
• Reduce TLB (Translation Lookaside Buffer) misses.
• Improve performance for memory-intensive workloads like databases and virtual
machines.
5. NUMA-aware Memory Management
NUMA (Non-Uniform Memory Access) systems consist of multiple CPUs, each with its own
local memory.
• Access to local memory is faster than remote memory.
• NUMA-aware OS schedules processes close to their memory.
• Balances performance by reducing remote memory access.
Diagram:
[CPU1 ↔ Local Memory1] [CPU2 ↔ Local Memory2] (Remote access is slower)
6. Resource Allocation in Cloud-native Environments
• In cloud-native systems (Kubernetes, Docker), resources like CPU, memory, and storage
are dynamically allocated.
• Resource allocation policies ensure fairness, isolation, and scalability.
• Techniques:
- Cgroups and namespaces for isolation.
- Horizontal scaling (adding more instances).
- Vertical scaling (increasing resources of a single instance).
• Auto-scaling based on workload demand.
7. Activity: Simulate Demand Paging and Page Replacement Algorithms
Objective: Simulate demand paging and evaluate page replacement algorithms.
Steps:
1. Define a reference string of page requests.
2. Allocate limited memory frames.
3. Apply page replacement algorithms (FIFO, LRU, Optimal).
4. Count page faults and compare performance.
Example:
Reference string: 7, 0, 1, 2, 0, 3, 0, 4
Frames = 3 → Apply FIFO → Track page faults.