Finally finished the things that Lab1
manages storage media
cpu memory io device
memory at a time minimum unit 8 bit
computer bus 32 bit
There is a lot of data to read and write, there is a cache in the CPU
Memory hierarchy, two levels of cache
Operating system memory management
Memory is accessed in bytes
Disk sector number 512 bytes per sector minimum unit
Requirements for memory management systems
Abstraction, protection, sharing, virtualization
Memory management mechanism:
+ Relocation: (relocation)
+ Segmentation: (segmentation)
+ Paging: (paging)
+ Virtual storage (virtual memory)
Most systems require paged virtual storage
Address Space & Address Generation
From the written symbol to the physical address on the bus
Address space:
The address space supported by hardware in the physical address space starts at 0. Knowing the MAXsys
logical address space, the address seen by the process when the CPU is running is 0- MAX prog
Logical addresses are converted to physical addresses according to the method
Generation of logical addresses
When compiling:
Assume start address is known
Must recompile if start address changes
When loading:
the starting position at compile time, when the compiler generates relocable code (reloctable code)
when loading, it generates an absolute address
Execution time:
code can be moved while executing
Address translation (mapping) hardware support is required
地址的生成过程:
logical address to physical address subpoena
address check
contiguous memory allocation
Contiguous memory allocation and memory fragmentation
You have to allocate 510 bytes and you allocate 512 bytes. The remaining bytes are internal fragmentation
depending on whether the allocation unit size is rounded.
Dynamic Partition Assignment
first match strategy
Free partition list
First Fit Allocation
Best Fit Allocation
Merging is slow because the address to find is close but it is sorted by size
Wrost Fit Allocation
defragmentation
Compact (ompaction)
Fragment compact: whether there is an application, it can be dynamically relocated
Partition swap
Swapping in/out
swap to swap area
The program in the waiting state is moved to the external memory area
and there is a swap area
buddy system
Implementation of Buddy System
The size of the entire allocatable partition
data structure
Two-dimensional array of free blocks, the
first dimension is sorted from small to large, and the
same size is sorted by address
Physical memory management in u core
ucore has implemented