6.1 basic concepts of memory
Primary memory management is still a very important part of the operating system today. The rational and effective use of primary memory reflects the performance of the operating system, and directly affects the role of the entire computer system.
6.1.1 Memory Level
Currently, in many computer systems, a three-level memory structure is used, namely, high-speed buffer memory, primary memory, and external memory.
Comparison of Level 3 memory
From high-speed cache to external storage, the capacity is getting bigger and bigger. Generally, the difference between each level is several orders of magnitude. The data access speed is getting slower and cheaper.
6.1.2 address relocation
To find out what is relocation, we first introduce the concepts of relative addresses, absolute addresses, logical address spaces, and buckets.
1. Logical Address Space
Namespace
When you program or edit a source program, you store the source program in the symbolic namespace (namespace for short) created by the programmer, regardless of the storage space allocation between jobs, 6-1 (.
Logical Address Space
When the source program is compiled, the address range defined by the compiled target program is called the logical address space of the job.
Figure 6-1 space, address space, and storage space
6-1 (B.
2. Physical space
The so-called physical space (also called a bucket) refers to the set of physical units in the primary storage. The numbers of these units are called physical addresses or absolute addresses. Therefore, the size of physical space is determined by the actual capacity of the primary storage. 6-1 (c ).
3. Address relocation
Example of address relocation
6-2 (a) is a simple program segment. The first command is to get data a to register 1. The second command is to add the content of Data B to register 1. The result is placed in register 1, the third instruction is to send the content of register 1 to the relative address 10. If the program is loaded into the primary storage from the storage zone (6-2 (B) starting with the 100 yuan, it cannot be correctly executed.
Address relocation
Because a job is loaded into a bucket that is inconsistent with the address space, the adjustment process of the relevant address is called address relocation. This adjustment process is to convert the logical address used in the job address space into the physical address in the primary storage. This address transformation is also called address ing.
Figure 6-2 example of program loading
4. Relocation type
Address relocation can be divided into static relocation and dynamic relocation based on the time and technical means used for address transformation.
Static relocation
(1) Meaning
Static relocation is completed by the assembly program before the program runs. In the case in Figure 5-2 (a), you only need to add 100 to all the items related to the address, as shown in Figure 5-2 (c ).
(2) Advantages
Its main advantage is that it can be implemented on a general computer without the need to add a hardware address translation mechanism.
(3) Disadvantages
Main disadvantages:
① It is required to allocate a continuous storage space for each job, and the job cannot be moved during the entire execution period, so it cannot be re-allocated.
② The user must determine the required storage capacity in advance. If the required storage capacity exceeds the available storage space, the user must consider the overwrite structure.
③ It is difficult for users to share copies of the same program in the primary storage.
Dynamic Relocation
(1) Meaning
Dynamic Relocation is implemented by the hardware address translation mechanism during program execution.
(2) Example
The simplest method is to use a relocation register. The value of this register is set by the scheduler based on the start address of the bucket assigned to the job. In a computer system with such an address translation mechanism, when a job is executed, it does not access the master Memory Based on the logical address given by the CPU, the address obtained after adding the logical address and the content in the relocation register is used as the address for accessing the primary memory. Address conversion process
6-3 Relocation type
Figure 6-3 dynamic relocation
(3) The main advantages of dynamic relocation include:
① User jobs do not need to be allocated continuous storage space.
② During the execution of a user job, you can dynamically apply for a bucket and move it in the primary storage.
③ Facilitates the sharing of program segments.
(4) The main disadvantages of dynamic relocation are:
① Additional hardware support is required.
② Software algorithms for implementing storage management are complicated.