Introduction

Memory Management is the operating system function that assigns and manages the computer's primary memory. The capacity of the computer's memory was one of the key constraints imposed on programmers in the early days of computers. The application could not be loaded if it was larger than the available memory, severely limiting program size. The earliest and most fundamental mechanism for storing many processes in main memory is the Fixed Partitioning Technique. The underlying problem with fixed partitioning is that the size of a process is restricted by the maximum partition size, which implies that one process can never span another. The obvious solution would be expanding the available RAM, but this would significantly raise the cost of the computer system. So, earlier individuals have employed a method known as Overlays to tackle this problem.
What is overlay in OS?
Overlays in Memory Management operate on the premise that when a process runs, it does not consume the complete program at the same time but rather a subset of it.
Then, the overlaying concept is that you load whatever component you want, and when the section is completed, you unload it, which means you pull it back and get the new part you require and execute it.
Overlaying is defined as "the process of inserting a block of computer code or other data into internal memory, replacing what is already there."
It is a method that permits applications to be larger than the primary memory.
Because of the limitations of physical memory (internal memory for a system-on-chip) and the absence of virtual memory features, overlaying is generally employed by embedded systems.
Also See, FCFS Scheduling Algorithm
Example of Overlays
Let us take the example of an Assembler.
Consider that an assembler has two passes.
Having two passes indicates that it will only be performing one thing at a time, either the first or second pass.
This indicates that it will complete the first pass first, followed by the second pass.
Assume that the available main memory is 170KB and the overall code size is 230KB.
Pass 1.......................80KB
Pass 2.......................90KB
Symbol table.................30KB
Common routine...............20K
It is not feasible to utilize two passes at the same time since the overall code size is 230KB, and the primary memory size is 170KB.
So, we need to use the overlays technique here :
Overlays Driver: Overlaying is completely user-dependent. Even what component is necessary for the first pass should be written by the user.
And after the first pass is completed, the user should write the code to take out pass 1 and load pass 2. This responsibility of the user is known as Overlays driver.
Suppose the Overlays driver is 10KB.
Now we need to find out the minimum partition size required.
So, total memory needed for Pass 1=Pass1+Symbol Table+Common routine
= (80+30+20+10)KB= 140KB
Similarly, total memory needed for pass 2=(90+30+20+10)KB=150KB
So, To run the code easily, we need to have a partition of a minimum size of 150KB.
Must Read Process Management in OS