Program loading 3 modes 1.Absolute loading mode 2.Relocatable loading mode 3.Dynamic run-time loading 4口”4814在,4色,主)QC
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Program loading ▶ 3 modes 1. Absolute loading mode 2. Relocatable loading mode 3. Dynamic run-time loading
Program loading 1.Absolute loading mode(绝对装入方式) Compiling: Operating system Absolute code with absolute addresses Loading: Must be loaded into the specified address user Loading address absolute address Execution: Logical address absolute address Suitable for simple batch systems(单道 系统) 512K 4口”484在4色,主月QC
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Program loading 1. Absolute loading mode (绝对装入方式) ▶ Compiling: ▶ Absolute code with absolute addresses ▶ Loading: ▶ Must be loaded into the specified address ▶ Loading address = absolute address ▶ Execution: ▶ Logical address = absolute address ▶ Suitable for simple batch systems (单道 系统) Operating system user 0 512K
Program loading 2.Relocatable loading mode(可重定位装入方式) Mostly,the loading address can not be known at compile time,but only be decided at load time. Compiling: Relocatable code with relative addresses Loading: According to loading address,relative addresses in file is modified to absolute addresses in memory 参This is called relocation(重定位) Static relocation(静态重定位): because the address binding is completed one-time at load time,and will not be changed after Execution: Logical address absolute address Suitable for multiprogramming systems(多道系统) 口”4814在4色,主QC
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Program loading 2. Relocatable loading mode (可重定位装入方式) ▶ Mostly, the loading address can not be known at compile time, but only be decided at load time. ▶ Compiling: ▶ Relocatable code with relative addresses ▶ Loading: ▶ According to loading address, relative addresses in file is modified to absolute addresses in memory ▶ This is called relocation (重定位) ▶ Static relocation (静态重定位): because the address binding is completed one-time at load time, and will not be changed after ▶ Execution: ▶ Logical address = absolute address ▶ Suitable for multiprogramming systems (多道系统)
Program loading 2.Relocatable loading mode(何重定位装入方式) The in-memory location of a program may be changed,that is,the physical addresses is changed during execution Example:swapping How?To postpone the relocation time to real execution ynamic run-time relocation(动态运行时重定位) Loading: Addresses in memory relative address Execution: Logical address relative address need MMU with relocation register ot把 14000 logical CPU address memory 346 14346 MMU 口”4814三#4色,主月QC
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Program loading 2. Relocatable loading mode (可重定位装入方式) ▶ The in-memory location of a program may be changed, that is, the physical addresses is changed during execution ▶ Example: swapping ▶ How? ⇒ To postpone the relocation time to real execution dynamic run-time relocation (动态运行时重定位) ▶ Loading: Addresses in memory = relative address ▶ Execution: Logical address = relative address ▶ need MMU with relocation register CPU relocation register MMU 14000 ✚✙ ✛✘+ logical address ✲ 346 physical address ✲ 14346 memory
Program loading 3.Dynamic Loading(动态运行时装入方式) Based on the principle of locality of reference(局部性 原理) The main program is loaded into memory and is executed Routine is not loaded until it is called Loading while execution:need the relocatable linking loader before loading:relocatable code while calling and not in: load the desired routine,update the program's address tables and the control is passed to the newly loaded routine Advantage: Better memory-space utilization; unused routine is never loaded. Useful when large amounts of code are needed to handle infrequently occurring cases Example:Error routine No special support from OS is required Due to the users Special library routines that implementing dynamic loading are needed 口”4614三4色,主月QC
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Program loading 3. Dynamic Loading (动态运行时装入方式) ▶ Based on the principle of locality of reference (局部性 原理) ▶ The main program is loaded into memory and is executed ▶ Routine is not loaded until it is called ▶ Loading while execution: need the relocatable linking loader ▶ before loading: relocatable code ▶ while calling and not in: load the desired routine, update the program’s address tables and the control is passed to the newly loaded routine ▶ Advantage: ▶ Better memory-space utilization; ▶ unused routine is never loaded. ▶ Useful when large amounts of code are needed to handle infrequently occurring cases ▶ Example: Error routine ▶ No special support from OS is required ▶ Due to the users ▶ Special library routines that implementing dynamic loading are needed