What the operating system does
- Allocation and recovery of memory space
advantage | Disadvantage | |||
---|---|---|---|---|
Contiguous memory allocation | Single continuous allocation | The memory is divided into system area and user area There can only be one user program in the memory, which occupies the entire user area space exclusively |
Simple to implement No external fragments Can use overlay technology to expand memory Memory protection is not necessary |
Can only be used in single-user and single-task operating systems y has internal fragments Low memory utilization |
Fixed partition allocation | Divide the entire user area into several fixed-size partitions, and load only one job in each partition to support multi-program systems When fixed size means the size of the partition remains the same, but different partitions may have different sizes Create a partition description table to realize the allocation and recovery of each partition. Each entry includes the size, starting address, and status of the partition. |
Simple to implement No external fragments |
When the program is too large, all partitions cannot meet the requirement, and overlay technology should be used to solve the problem. Will produce internal fragmentation and low memory utilization |
|
Dynamic partition allocation | The memory partition is not divided in advance, but when the process enters the memory, the partition is dynamically created according to the size of the process, and the size is just suitable. Common data structure: 1. Free partition table 2. Free partition chain |
No internal debris | There are external fragments | |
Discrete memory allocation | ||||
TIPS:
|
- Use a certain technology to logically expand the memory space
- Covering technology
- Exchange technology
- Virtual storage technology
thought | Disadvantage | |
---|---|---|
Covering technology | Divide the program into multiple segments, the commonly used segments are resident in the "fixed area" of the memory, and the less frequently used segments are transferred to the memory "covered area" when needed, and called out when not in use The memory is divided into a "fixed area" and several "coverage areas" Let the blocks that cannot be called at the same time share a coverage area |
Opaque to users, increasing programming burden (Applicable to earlier operating systems) |
Exchange technology | When the memory space is tight, some processes can be temporarily swapped out to the external memory (become suspended), and the processes that have met the operating conditions in the external memory can be swapped into the memory (PCB must be resident in memory) Usually the disk (that is, the external storage) is divided into a file area and a swap area Blocking or low-priority processes can be swapped out first, sometimes considering the memory residence time |
|
Virtual storage technology | (It will be recorded separately in the next blog) |
- Address relocation (logical address to physical address)
-
Three loading methods period the way Absolute loading Single program stage Absolute address generated at compile time Relocatable loading Early multi-pass batch processing stage Convert logical address to physical address when loading 动态运行时装入 现代操作系统 运行时将逻辑地址转换为物理地址,需设置重定位寄存器
-
- 内存保护功能(两种方法)
- 在cpu中设置一对上下限寄存器,存放进程的上下限地址,用于检测指令是否越界
- 采用重定位寄存器(基址寄存器)和界地址寄存器(限长寄存器)进行越界检查