 Hello everyone, today we are going to see the dynamic loading and dynamic linking. Learning outcome. At the end of this session, students will be able to explain the dynamic loading and the dynamic linking. Now first we see the dynamic loading. Sometimes a program may require more storage space than the available one. Even the execution of such program can be possible if all the segments are not required simultaneously to be present in the main memory. In such situation, only those segments are resident in the memory that are actually needed at the time of execution. But the question arises, what will happen if the required segment is not present in the memory? Naturally, the execution process will be delayed until the required segment gets loaded in the memory. And the overall effect of this is efficiency of the execution process gets degraded. The efficiency can then be improved by carefully selecting all the interdependent segment. Of course, the assembler cannot do this task. Only the user can specify such dependencies. Then the interdependency of the segments can be specified by a tree-like structure called as overlay structure. The overlay structure contains the multiple nodes and the edges. And each node represents the segment. The specification of the required amount of memory is also essential in this structure. And the two segments that can lie simultaneously in the main memory if they are on the same path. Usually the sub-routines of the program are needed at different times. For example, the pass 1 and the pass 2 of an assembler are mutually exclusive. By explicitly recognizing which sub-routine calls other sub-routines, it is possible to produce the overlay structure that identifies mutually exclusive sub-routines. Now, here the first figure shows the sub-routine calls between the procedure. Figure illustrates a program consisting of the five sub-programs A, B, C, D and E that requires the 100 kb of the core. The arrow indicates that sub-program A only calls the B, D and E. Sub-program B only calls the C and E. Sub-program D only calls the E. And sub-program C and E do not call any other sub-routines. Now, figure 2 shows the sub-routine calls between the procedure. Figure 2 highlights the interdependencies between the procedure. Here the procedure B and D are never in use at the same time. Similarly, neither procedure C and E also. But if we load only those procedures that are actually to be used at any particular time, then the amount of core needed is equal to the longest path of the overlay structure. And this happens to be the 70 k for the example in figure 2, procedure A, B and C. Now, figure 3 shows a storage assignment for each procedure that is consisting with the overlay structure. Here this is a figure for possible storage assignment of each procedure. Here the procedures A, B, C, D, E are stored for the overlay structure to work. It is necessary for the model loader to load the various procedures as they are needed. The portion of the loader that actually intercepts the calls and it loads the necessary procedures called the overlay supervisor. It called the overlay supervisor or simply the flipper. And this overall scheme is called as dynamic loading or we can say that load on call. Now after seeing the concept, can you tell me dash are used for reduce the main memory requirement of the program. The options are hips, overlays, graphs, none of the above. Pause the video and think about it. The answer is overlays. Overlays are used for reduce the main memory requirements of the program. Now next we see the dynamic linking. As we have seen in overlay structure, the certain selective subroutines can be resident in the memory. That means it is not necessary to resident all the subroutines in the memory for all the time. Only the necessary routines can be present in the main memory and during the execution. The required subroutine can be loaded in the memory. But this process of postponing the linking and loading of external references until the execution is called the dynamic linking. For example, suppose the subroutine main calls A, B, C, D. Then it is not desirable to load the A, B, C and D along with the main in the memory. Whether the A, B, C or D is called by the main or not will be known only at the time of execution. Hence keeping these routines already before is really not needed. As the subroutines get executed when the program runs and also the linking of all the subroutines has to be performed. And the code of all the subroutines remains resident in the main memory. As a result of all this is that the memory gets occupied unnecessarily. But typically error routines are such routines which can be invoked rarely. Then one can postpone the loading of these routines during the execution. If the linking and loading of such rarely invoked external references then could not be postponed until the execution time. The linking and loading of such rarely invoked external references could be postponed until the execution time when it was found to be absolutely necessary. Then it increases the efficiency of the overhead of the loader. In dynamic linking the binder first prepares a load model in which along with the program code the allocation and the relocation information is stored. Then the assembler produces the text, binding and relocation information from a source program. The loader simply loads the main module in the main memory. The main program executes a transfer instruction to an external addresses and then the loader is called. If any external reference to a subroutine comes then the execution is suspended for a while. Then the loader brings the required subroutine in the main memory and then the execution process is resumed. Thus in dynamic linking both the loading and linking is done dynamically. Now next we see the advantages of dynamic loading. Now first advantage is that the overhead on the loader is reduced. The required subroutine will be load in the main memory only at the time of execution. And the second advantage is that the system can be dynamically reconfigured. Now next we see the disadvantage. Overhead and the complexity is included because postponed binding process until the execution time. The linking and loading need to be postponed until the execution. During the execution if at all any subroutine is needed then the process of execution needs to be suspended until the required subroutine gets loaded in the main memory. Gets loaded in the main memory. Now these are the references. Thank you.