Memory Management Notes
MEMORY MANAGEMENT
Overview of Memory Management
- Memory management is crucial in multi-user and multiprogramming environments.
- It handles the allocation and deallocation of physical memory to processes.
- Central to the operation of a computer, it supports the "Stored Program" concept.
Four Functions of Memory Management
- Allocation Status Tracking:
- Monitor memory usage to identify free and allocated spaces.
- Allocation Policy Determination:
- Establish methods to decide how much memory each process receives, especially with multiprogramming.
- Memory Allocation:
- Assign specific memory locations to processes based on the allocation policy.
- Memory Deallocation:
- Release memory once a process has finished executing and update the status of memory locations.
Memory Management Techniques
Contiguous Allocation Memory Management
- Allocates memory in a contiguous block.
- Types Include:
- Single Contiguous Allocation
- Partitioned Allocation
- Relocatable Partitioned Allocation
- Allocates memory in a contiguous block.
Non-Contiguous Allocation Memory Management
- Allows processes to be allocated non-contiguous memory areas.
- Implemented Through:
- Paged Memory Management
- Virtual Memory Management
- Allows processes to be allocated non-contiguous memory areas.
Logical vs Physical Address
- Logical Address:
- Address generated by the CPU (also called virtual address).
- Physical Address:
- Actual address on the storage device used to access data.
Contiguous Allocation Memory Management
Single Contiguous Allocation:
- Simple method requiring minimal hardware support.
- Memory divided into OS (kernel) and user space; multiple processes are not supported simultaneously.
- Example: Microsoft DOS.
Partitioned Allocation:
- Divides physical memory into partitions, each assigned to a process.
- Can be Static (fixed size) or Dynamic (variable size).
- Requires both Base and Limit registers for hardware support to ensure process isolation.
Advantages:
- Supports multiple processes, minimal hardware required.
Disadvantages:
- Wastage of memory, fragmentation, pathologies from static allocation failure if jobs exceed allocated partitions.
Non-Contiguous Allocation Memory Management
- Paged Memory Management:
- Splits both logical address space and physical memory into equal-sized pieces (
pages). - Involves a Page Map Table (PMT) for mapping logical pages to physical memory.
- Splits both logical address space and physical memory into equal-sized pieces (
Virtual Memory Management
- Allows the system to use memory more efficiently by allowing processes to execute without needing the entire address space loaded in physical memory at once.
- Uses techniques like Demand Paging to load pages as needed and Segmentation for modularity.
- Advantages:
- Increased efficiency beyond 100% utilization of physical memory, supports larger address spaces without requiring full availability.
- Disadvantages:
- Increased hardware costs, potential for thrashing (excessive swapping).
Thrashing and Locality of Reference
- Thrashing: Occurs when many processes compete for limited memory resources, leading to excessive paging and reduced system throughput.
- Locality of Reference: Programs tend to access a limited set of memory locations repeatedly within short periods, promoting the effectiveness of caching and paging techniques.
Address Translation in Segmented Demand Paging
- Virtual address
v(s,p,d):s: Segment numberp: Page number within that segmentd: Displacement within the page
- Protection: Each segment has associated access rights defined in the segment map to control which processes can access it.
Swapping & Overlays
- Swapping:
- Temporary removal of process from memory to disk to make room for other processes.
- Aimed at maintaining system performance and efficient memory utilization.
- Overlays:
- Used to extend memory capabilities by loading only necessary portions of a program into memory, swapping in and out as needed without requiring large contiguous blocks of memory.
Summary of Memory Management Schemes
- Contiguous allocation suited for smaller, simpler systems.
- Paging and segmentation support larger, more complex applications with dynamic memory requirements.
- Swapping and overlays are techniques to optimize memory usage, especially useful in systems with heavy multitasking.