Computer storage management comprehensive arrangement (a) the basic principles and requirements of memory management
After reading the chapter of the storage system in the principle of computer composition, combined with the memory management and file management in the operating system, I have a new understanding of the storage management of the entire computer, and here I will summarize it together.
First of all, I will throw out a few new understandings after reading it in general:
- Computer storage management is hierarchical, from cache to memory to external memory, the speed is reduced in turn, the size is gradually increased, and the price is gradually cheaper.
- The speed at which the CPU obtains data from these three layers gradually decreases. We have done so many operations in storage management. In fact, it is to save money at the same time, not only improve the access speed (locality principle, layer-by-layer cache), but also improve the available address space (virtual memory).
- No matter which level, the problems faced are address mapping, space allocation, and replacement strategy when space is not enough (the three are strongly correlated, such as the allocation method of paging, address mapping It is necessary to use the page table, the allocation method of request paging, and the allocation and replacement of space are also strongly correlated).
- Replacement strategies are only needed when there is insufficient space, such as cache replacement, such as request-style paged memory. Like continuous allocation or ordinary paging allocation, there is no replacement strategy. If there is not enough space, it will not be allocated, and there is no problem of which memory to temporarily replace.
- Various space management methods are not independent, but have an inherent progressive relationship. Taking memory allocation as an example, it is continuous allocation at the beginning, but it is found that continuous allocation is prone to fragmentation problems, so it is thought of discontinuous allocation. Discontinuous allocation is divided into segmentation, paging and segment paging, but note that so far, it is only a problem of memory allocation, and the entire program still needs to be completely loaded into memory at the beginning. Therefore, we put forward the concept of virtual memory. In order to match the virtual memory, we upgrade the segmentation, paging and segment page type to request type, and there will be more fields in the page table entry or segment table entry for the external memory address when the page is missing., there will be more fields for the flag when memory is replaced.
- Paging/segment and virtual memory are two different things. Paging is a way of space allocation, and virtual memory is a way to logically expand Memory Space, but virtual memory uses requested paging or segmentation.
- Continuous allocation and basic paging segmentation only have allocation strategies, such as first adaptation algorithm, near adaptation algorithm, etc., but there is no special replacement strategy, there is no replacement when the program is still running, it is all allocated at one time, and it can be allocated. Run and uninstall all at once after running. And its allocation strategy like request paging also involves replacement strategy.
- The memory access path of modern operating systems is roughly as follows: first, the program gives the relative address of virtual memory for instructions or data, then obtains the actual address of virtual memory through address relocation, and then queries whether the segment table or page table has been loaded into memory. In memory, if it is loaded into memory and in cache, it will return directly from cache. If it is in memory and no longer in cache, it will be loaded from memory and updated cache (replacement may occur). If it is not in memory, it will be loaded from page Find the external memory address in the table entry, load it into memory (replacement may occur), and then return to the CPU and update the cache No.