Skip to content

Program Loading

Main processing stage of the program

  • Edit, compile, link, load, execute

Program loading

  • Program loading is the process of loading target program code from external memory to main memory for execution by the CPU. Different loading methods determine the layout of the program in main memory and how address translation is implemented.

Loading method

Absolute loading mode: The compiler generates absolute address object code.

Relocatable loading method: The starting address of the target module is 0, and the rest are relative addresses.

Dynamic runtime loading mode: The memory image of a process can be in different locations at different times.

Absolute loading method

  • Compile-time determination: If it is known at compile time that the program resides at a specific location in main memory, the compiler will generate object code for the physical address.
  • Loading process: The absolute loader loads programs and data into the main memory according to the address in the loaded module.
  • Address consistent: After the module is installed, the logical address in the program is exactly the same as the actual main memory address, so there is no need to modify the address.
  • Applicable Scenarios: Only applicable to single-programming environment. The target module can only be loaded into the fixed location specified in advance in the main memory.

Static relocation loading method

  • Address conversion: When loading the operation, convert the instruction address and data address in the operation into physical addresses all at once.
  • Execution Process: No need to perform address translation during job execution.
  • Static Relocation: This address translation method is called "static relocation", and the job loading method is called "static relocation loading method".

Dynamic relocation loading method

  • Loading process: When loading a job, load the job directly into the assigned main memory area.
  • Address Conversion: During the execution of the job, the hardware address conversion mechanism automatically converts the logical address in the instruction into the corresponding physical address.
  • Dynamic completion: This kind of address translation is completed dynamically during the execution of the job, which is called "dynamic relocation".
  • Dynamic relocation loading method: This method of job loading is called "dynamic relocation loading method".