Contiguous Memory Management
Continuous storage management refers to managing the user area in the main memory as a continuous area or multiple continuous areas. Its main methods include single continuous allocation, fixed partition allocation, and variable partition allocation.
Single continuous storage management
- Basic concept: Single continuous storage management is the simplest storage management method. The operating system occupies a part of the main memory space, and the remaining part is allocated to a job as a continuous partition, so there is at most one job in the main memory at any time.
- Advantage: This method does not need to consider the movement of jobs in the main memory, and usually uses static relocation to convert addresses to ensure storage protection.
- Disadvantage:
- Low CPU utilization: When the job is waiting, the CPU is idle.
- Low memory utilization: Regardless of the size of the job, the main memory space can only be allocated to one job.
- Low peripheral device utilization.
Fixed partition storage management
- Allocation and recovery: The system manages the allocation of each partition through the "main memory allocation table" and uses a sequential allocation algorithm to allocate main memory space. When the job is completed, the occupied partition is returned.
- Address translation and storage protection: Static relocation loading is used to add the logical address of the job to the lower limit address of the partition to get the physical address. The physical address needs to be within the upper and lower limits of the partition, otherwise the "address out of bounds" interrupt is triggered.
- Main memory space utilization: Fixed partition management will lead to a certain amount of memory waste ("fragmentation"), and the space utilization can be improved by the following methods:
- Partitions are divided according to job size and frequency.
- Partitions are arranged in order of size.
- Jobs are divided into multiple queues according to job requirements.
Variable partition storage management
- Basic concepts: The system manages the main memory space through the free partition table. When the job is loaded, a free partition of suitable size is allocated from the free partition.
- Allocation algorithm:
- First fit allocation algorithm: Sequentially search the free partition table and select the first free partition that meets the job requirements.
- Optimal fit allocation algorithm: Select the smallest free partition for allocation to reserve a larger free space.
- Worst fit allocation algorithm: Select the largest free partition for allocation to avoid leaving too small free space.
- Reclaim and merge: After the job is completed, the partition it occupies is reclaimed. During the recycling process, it will check whether there are adjacent free partitions. If there are, they will be merged into a larger free partition.
- Address translation and storage protection: Dynamic relocation loading is adopted to implement address translation and storage protection through base address registers and length limit registers. If the logical address exceeds the partition range, the system will trigger an "address out of bounds" interrupt.
Overlay and swap technology
-
Overlay technology: The program is divided into multiple functional modules, only the necessary modules are resident in the main memory, and the infrequently used modules are stored in the external memory and loaded into the main memory as needed. This technology can solve the problem of running large jobs in a small main memory, but it increases the complexity of programming.
-
Swap technology: Swap temporarily inoperable processes or unused programs and data from the main memory to the external memory to make room for loading new processes or programs. The swap process is managed by the operating system and is transparent to the programmer. Swapping is often used between processes, while overlay is performed within the same process.