Address Binding :-
A program is actually an executable file stored on the disk. To execute the program, it has to be brought in the main memory and placed inside a process. The processes generally move between disk and memory during execution. A special queue called as "Input Queue" is used to place the processes that are ready to brought into the memory. One process from this input queue is selected and brought into the memory. The process executes and accesses instructions and data from memory. When the process is terminated, the amount of memory that is acquired by the process is released.
Most of the popular operating systems allow placing of a user process in any part of the main memory. This means the starting address of a user program and the memory should not be the same. All addresses in the program are converted into actual physical addresses. It is the job of the complier to bind these symbolic addresses of program to relocatable addresses. The linkage editor or loader binds these relocatable addresses to absolute addresses.
The binding of instructions and data to memory addresses can be done at any step of processing of user program.
(a) Compile Time Binding :-
If the exact location of the process in the memory can be noticed at compile time, then the absolute code can be generated. This type of binding is called as compile time binding. For example, if you can make your complies to generate code starting at address. This will work find till the starting memory changes, the whole program will have to be rewritten.
(b) Load Time Binding :
- If the exact location of the process in the memory can be noticed at compile time, then the relocatable code can be generated. In this case, the final binding is delayed till the load time. In this scheme, if the starting address changes. The program is just reload to incorporate the changed value.
(c) Execution Time Binding :-
In the runtime or execution time binding, the binding of addresses is delayed till the runtime. This allows movement of process from one memory segment to the other. A special hardware called Memory Management Unit is used for this kind of binding. Most of the modern operating systems use this type of binding.
Physical And Logical Addressing :-
There are two types of addresses that are used by operating system to execute the user program. The actual addresses that refer to the actual physical location of the main memory are called as Physical Addresses whereas the addresses generated by CPU are referred to as Logical Address.
Whenever we write a program is any language like C, we use variables to input and output data. These variables are actually stored in the main memory but the user is not aware of the actual physical address of the memory. The programs are developed by assuming that the first memory address will be given to first logical address of the program. When the program is taken to the memory for execution, a part of the memory management unit called "Relocation Register" adds”. A fixed value to each logical address generated by the user program and then it places the user program in resulting memory location.