Dynamic Loading
Suppose, there is a program with many modules. To execute, the program must be loaded into the main memory. Here, the question aries that, is it necessary to preload the entire program into memory? It is not good from memory point of view. Instead, only the main program is loaded into memory and other parts of the program (called routines) will be loaded when it is called. Dynamic loading is based on this technique.
Dynamic loading is the method to loading routine dynamically. The main purpose behind of dynamic loading is to obtain better utilization of memory space.
Overlay
Overlay came into existence to overcome the lack of memory space. Overlay is a technology that makes it possible to execute a program even when we do not have any required memory space available.
Overlays are used when the size of the process is greater than the amount of memory allocated to it. Suppose, a program is to be executed but we have no required space in memory. In that situation overlay does partition of this program. Instead of loading the entire program at once, it loads this partitions/passes in memory one by one. When the other pass is needed they are loaded in the space occupied by the previously pass. Only some common instructions will remain in the memory for all the passes.
Example of two pass assembler
Two pass assembler | |
---|---|
Pass 1 | 70KB |
Pass 2 | 80KB |
Symbol Table Common Routines | 20KB 30KB |
According to above example, to load both the passes at once, we require 200KB space. If only 150KB available then we can not run our process. To solve this, we define two passes.