Storage management that does not produce internal fragmentation is: segmented storage management. In the segmented storage management method, the address space of the job is divided into several segments, and each segment defines a set of logical information. Each segment is addressed starting from 0 and uses a continuous address space. The address space of the entire job is two-dimensional because it is divided into multiple segments.
Storage management that does not produce internal fragmentation is: segmented storage management. Only paged storage management has internal fragmentation, and segmented storage management has external fragmentation.
Paging storage management
Paging storage management divides the logical address space of a process into several equal-sized slices. It is called page or page, and each page is numbered, starting from 0, such as page 0, page 1, etc.
Correspondingly, the memory space is also divided into several storage blocks of the same size as the page, called (physical) blocks or page frames (frames), and they are also numbered, such as 0# block, 1 #blocks etc. When allocating memory to a process, several pages in the process are loaded in block units into multiple physical blocks that may not be contiguous. Because the last page of the process often does not fit into one piece, unusable fragmentation is formed, which is called "in-page fragmentation".
Segmented storage management
The purpose of introducing segmented storage management is mainly to satisfy users (programmers) in programming and usage requirements, some of which are difficult to meet with other storage management methods. As a result, this storage management approach has become the basis for all storage management approaches today.
In the segmented storage management method, the address space of the job is divided into several segments, and each segment defines a set of logical information. For example, there are main program segment MAIN, subprogram segment X, data segment D, stack segment S, etc. Each segment has its own name. For the sake of simplicity, a segment number can usually be used instead of the segment name. Each segment is addressed starting from 0 and uses a continuous address space. The length of the segment is determined by the length of the corresponding logical information group, so the length of each segment is different. Since the address space of the entire job is divided into multiple segments, it is two-dimensional. That is, its logical address consists of the segment number (segment name) and the address within the segment.
The address in the segmented address has the following structure:
In this address structure, a job is allowed to have up to 64 K segments, each The maximum length of a segment is 64 KB. The segmentation method has been supported by many compilers, and the compiler can automatically generate several segments based on the source program. For example, the Pascal compiler can create separate sections for global variables, the procedure call stack used to store the corresponding parameters and return addresses, the code portion of each procedure or function, the local variables of each procedure or function, and so on. Similarly, the Fortran compiler can create separate sections for common blocks and can allocate a separate section for arrays. The loader loads all these segments and assigns each segment a segment number.
The segmented storage management method is introduced mainly to meet the following series of needs of users and programmers:
1) Convenient programming
Usually, users divide their jobs into several segments according to logical relationships. Each segment is addressed starting from 0 and has its own name and length. Therefore, the logical address you want to access is determined by the segment name (segment number) and the intra-segment offset (intra-segment address). For example, the following two instructions use the segment name and address within the segment:
LOAD 1, [A] | 〈D〉;
STORE 1, [B] | 〈C〉 ;
Among them, the meaning of the former instruction is to read the value in unit D in segment A into register 1; the meaning of the latter instruction is to store the contents of register 1 into unit C in segment B. .
2) Information sharing
When realizing the sharing of programs and data, it is based on the logical unit of information. For example, share certain routines and functions. The "page" in the paging system is only a physical unit (block) for storing information, which has no complete meaning and is not convenient for sharing; however, a segment is a logical unit of information. It can be seen from this that in order to achieve segment sharing, it is hoped that storage management can be adapted to the organization method of user program segments.
3) Information protection
Information protection also protects the logical units of information. Therefore, the segmented management method can realize the information protection function more effectively and conveniently.
4) Dynamic growth
In practical applications, some segments, especially data segments, will continue to grow during use, and it is impossible to know exactly how the data segments will grow in advance. How old is it? The other storage management methods mentioned above are difficult to cope with this dynamic growth situation, but the segmented storage management method can better solve this problem.
5) Dynamic link
Dynamic linking means that several target program segments are not linked together before the job is run. When it is to be run, first load the target program corresponding to the main program into the memory and start running. When a certain section needs to be called during the running process, the section (target program) is loaded into the memory and linked. It can be seen that dynamic links also require segments as the unit of management.
For more related knowledge, please visit: PHP Chinese website!
The above is the detailed content of What is storage management that does not create internal fragmentation?. For more information, please follow other related articles on the PHP Chinese website!