Address space, base and limit registers, dynamic relocation

An address space is a collection of addresses that a process can use to address memory. Each process has its own address space, and this address space is independent of the address spaces of other processes (except in some special cases where processes need to share their address space).

Each program is given its own address space, so that the physical address corresponding to address 28 in one program is different from the physical address corresponding to address 28 in another program. method:

base register and limit register

Using a simple dynamic relocation, each process' address space is mapped to a different part of physical memory . When using the base and limit registers, the program is loaded into contiguous free locations in memory without relocation during loading, as shown in Figure 3-2c. When a process runs, the starting physical address of the program is loaded into the base register and the length of the program is loaded into the limit register . In Figure 3-2c, when the first program runs, the base and limit values ​​loaded into these hardware registers are 0 and 16 384, respectively. When the second program runs, these values ​​are 16 384 and 16384 respectively. If the third 16KB program was loaded directly at the address of the second program and executed, the base and limit registers would have values ​​of 32 768 and 16 384.

Every time a process accesses memory , fetches an instruction, reads or writes a data word, the CPU hardware automatically adds the base address value to the address value sent by the process before sending the address to the memory bus . At the same time, it checks whether the address provided by the program is equal to or greater than the value in the limit register . If the accessed address exceeds the limit, an error is generated and the access is aborted. Thus, for the first instruction of the second program in Figure 3-2c, the program executes

 
 
  1. JMP 28 

instruction, but the hardware interprets this instruction as (28+16384=16412)

 
 
  1. JMP 16412 

So the program jumps to the CMP instruction as we want. During the execution of the second program in Figure 3-2c, the settings of the base and limit registers are shown in Figure 3-3.

  

Figure 3-2 Description of the relocation problem: a) a 16KB program; b) another 16KB program; c) two programs are loaded into memory consecutively

 

Using base and limit registers is a very easy way to give each process a private address space, because each memory address is automatically prepended with the contents of the base register before it is sent to memory . In many real systems, the base and limit registers are protected in such a way that only the operating system can modify them.

The disadvantage of using base and limit register relocations is that each memory access requires addition and comparison operations . Comparisons can be done quickly, but additions can be slow without the use of special circuitry due to carry-pass time issues.



Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325766650&siteId=291194637