Dynamic Binding : Explained


In dynamic binding, the addresses generated by the CPU are called logical addresses and these addresses are converted to physical addresses at runtime.


This article explains dynamic binding in detail.


Dynamic binding is what happens in most modern operating systems. In the runtime binding process can be moved to a different section of memory at a time. The addresses generated by the CPU are not physical addresses  CPU generates logical addresses and these addresses are converted to physical addresses at runtime. To implement runtime binding hardware support is required in the load time-binding, compile-time binding we could do it through software but runtime binding since the CPU is going to generate some logical addresses which need to be converted to some physical address at runtime it has to happen through hardware and there is something called memory management unit which converts these logical addresses to physical addresses.

The advantage of this is your process can move to a different location while it has begun. Let us now discuss how runtime binding happens.

It happens to hardware. There is a unit in the CPU that is called the memory management unit MMU and this unit has a limit resistor and a relocation register. When the process is loaded into memory when context switching happens these registers are loaded by the operating system, the operating system loads the register according to the slot of memory where this process is going to be loaded when the program is being run.CPU generates a logical address it does not have to worry about a physical address it does not have to know where is it in physical memory so when these logical addresses are generated the registers are used to convert these logical addresses to these physical address.

Limit register tells what is the limit of these processes, if a process generates a logical address beyond its memory allocation then the hardware sensor traps the operating system that there’s something wrong happening in the program otherwise it uses the relocation register, accesses the address of the relocation register and points the physical address so these things are done by hardware using relocation register and limit register.

The advantage is hardware helps you in doing security also your process cannot access its limit beyond its allowed limit whenever it happens your hardware sensor traps your operating system and then your operating system can generate an error. It is implemented in hardware because if you use software or operating system to do this context switching what will happen when you generate a logical address in OS, the system call will happen that will convert this logical address to a physical address which means mode switch will happen you will go from process context to OS context and then you will find the physical address and that is something you will do for every instruction generated by CPU which is going to be very very slow that is why it is implemented hardware.

Special thanks to Ami Jangid for contributing to this article on takeUforward. If you also wish to share your knowledge with the takeUforward fam, please check out this article