 Today we are going to discuss the topic linking of overlay structured programs. At the end of this session, a student will be able to demonstrate how linking is done for overlay structured programs. Let us look at the background now. In programming, some parts of the program are briefly executed or sometimes not executed at all. Therefore, we keep these programs not in the main memory at all time. Therefore, memory is reduced by not keeping these parts in the memory and called for when required only. Therefore, some parts of the program are given same load address during linking. But only one part is in memory at a particular time. Loading other parts in the same load address would overwrite it. Let us think now, how is the problem of overwriting handled? We go now to understand what are these overlay structured programs? Overlay is a part of the program with the same load origin as some other part of the program. The parts of the overlay structured program are a permanent resident program which is a root which contains procedures which are called over and over again. It may call data or it may call some other module of a program. The second part is a set of overlays to be loaded in the memory needed at a particular time when it is absolutely required. How does an overlay working continue? An overlay manager is a software that is linked with the root and this manager takes hold of all the actions of managing all the overlays which have to be put into the memory address at a particular time. The first root is loaded in memory and given the control of execution of a particular function. It invokes overlay manager to refer the function or the data in the overlay as the case may be. Overlay manager organizes the loading of the memory with required overlay and there is overwriting of previous overlays with the same load origin. The program designer designs overlays that do not call programs in other groups. Otherwise they would be an overwriting which is group dependent. Each group of program is put in a separate overlay. All overlays are given same load origin. Thus resulting overlay structure is then conveyed to the linker by linker control command. For an example let us try to understand how an assembler works. As we know a two pass assembler has two passes pass one and pass two where the passes form different overlays and the output of pass one is consumed by the pass two and therefore pass one can be one overlay generating data structures. After that is generated then the program that generates assembly language program that generates the pass one data structures can be removed from the memory only maintaining the data structures in the memory and the pass two can then be executed at the same address and therefore we are saving memory and we are using the same memory locations but the root program will be changing. For an analysis of designing the overlay program let us consider an example. A program which has sections in it for initialization and passing control to the read. Read for reading one set of data and invoking a function. The functions may be function A, function B or function C depending on the data values that are considered at a particular time. And all these functions are mutually exclusive a print which is called to print the results. Since all the functions that we consider are mutually exclusive we can put all these functions into separate overlays. The read and the print since they are used over and over again to call the other functions are put in the root of the program. In it is also put for convenience in the root of the particular program. Let us look at a proposed structure of the program. As we see on the left hand side executing an init first then a read then invoking the function A and then function B then function C and then print. We see that 65k bytes of memory are required. But if we go using overlay as seen on the right hand side we see that invoking a function A will take 40k because we are using the same memory locations. Invoking only the function B will take 35k and invoking the function C will take 30k. Therefore maximum the overlay structure can execute in 40k bytes though it has a total size of 65 kilobytes as we have seen on the left hand side. What are the changes then to be brought when using overlays in the linker basic algorithm? The basic change is in the assignment of the link addresses to the segments which are now considered as overlays. The variable which is programmed linked origin which is used while processing the root portion is variable now depending upon the overlays. And the size of the root decides the load address of overlays. We initialize programmed linked origin while processing each separate overlay. The second part that is of utmost consideration is when we are handling procedure calls that cross these overlay boundaries. The linker identifies inter overlay call and determines the destination overlay. Therefore the next overlay which is our destination is to be decided and given an address which is then told to the linker. All information is communicated to overlay manager who manages all the overlays that are required at a particular time. The third is the handling of object modules which is done through adding autolinking facility wherein we now consider these modules to be separate. Let us now try to think and answer as per the concepts we have just been introduced to. Which of the following is true? A. Overlays are used to increase the size of physical memory. B. Overlays are used to increase the logical address space. C. When overlays are used the size of the process is not limited to the size of the physical memory. And D. Overlays are used whenever the physical address space is smaller than the logical address space. We have come to a conclusion that the answer C is true. Because when overlays are used the size of the process is not limited to the size of the physical memory. It is only that we are going to use the same load origin for the particular overlay. Let us consider another question where we have to think what an overlay is. An overlay is A. A part of the operating system. B. A specific memory location. C. A single contagious memory that was used in the olden days for running large programs by swapping. D. Overloading the system with many user files. After all that we have heard we come to an answer that the answer is C. A single contagious memory that was used in the olden days for running large programs by swapping. Therefore the same memory addresses can be used for load origins for many overlays. For our references we have used. Thank you.