To run a process, the entire process and its data must be in physical memory. Thus, the size of a process is limited to the size of physical memory. The dynamic loading and linking are run-time operations.
The dynamic binding is a method to obtain better memory-space utilization. A routine is not loaded until it is called, until then all routine remains in the disk as relocatable code format.
A routing can call another routine, but it checks if another routine is loaded or not. If not, then relocatable linking loader is called to load the routine into memory and update program’s address tables to reflect this change. The control is passed to the newly loaded routine.
The total program may be large but only a small portion is loaded. The unused routine is never loaded into memory.
It is the programmer’s responsibility to implement dynamic loading, the OS can provide library routines to implement the dynamic loading.
In static linking, the system libraries are treated like any other object modules and combined by the loader into the executing program.
The dynamic linking, similar to dynamic loading is delayed until run-time. This feature is used with system libraries such as language subroutine libraries. Without this facility, each program must include a copy of its language library in the executable image which wastes memory space.
There are several benefits of dynamic linking:
– library routines not part of program code. A program is much smaller without the routines and loads faster into the memory.
– One copy of library routing is referred by many programs, therefore, saving disk space and memory space.
– Fixing bugs is easy because you are only required to fix a single routine, rather than individual copies of it.
The library can be updated with a newer version. Since the program must use the correct version of the library, the version information is included with the program and the library. Also, several version of the library is loaded into the memory, so that programs could use the correct copy of the library.
If the library has minor changes it retains the same version number. The version is incremented if the library has major changes, and affects the only program that is compiled using a newer version of the library. Old programs use an older version of libraries. This system is known as
Libraries require help from the operating system. If the processes in memory are protected from one another, OS checks if the required routine is already linked to another process, or allow multiple processes to access same memory addresses.
- Abraham Silberschatz, Peter B. Galvin, Greg Gagne (July 29, 2008) Operating System Concepts, 8 edn., : Wiley.
- Ramez Elmasri, A Carrick, David Levine (February 11, 2009) Operating Systems: A Spiral Approach, 1st edn., : McGraw-Hill Education.
- Tanenbaum, Andrew S. (March 3, 2001) Modern Operating Systems, 2nd edn., : Prentice Hall.