Memory is one of the most important Resources of the Computer System. Even though the memory in the recent times has become very large, but so also have the programs which use the memory. The more-the memory is expanding, the more increasing is the need for the memory. Therefore this requires for the Effective management of the Memory, so that the available memory can be used effectively. Most of the operating systems do provide this feature.
The part of the operating system that manages the memory is known as memory manager. The basic job of the memory manager is to keep track of the memory, the parts which are in use, the Unused Memory, to allocate memory for various processes and free the memory after the use. Swapping of the programs between main memory and Secondary Storagewhen required etc. the management of the memory can be classified into two major categories, which are as follows:
Memory Management without swapping between main memory and the secondary storage, memory management by swapping between main memory and the secondary storage.
Memory Management without Swapping
For Processing Single Program at a Time
This memory management is not that simple as its looks. The Simplest Form of the Memory Management is to have only one process in the memory at a time and allow the processes to use the total memory. This was an ongoing practice for quite a long time till early 1950s but, now it is not used, as this technique involves that process must contain all the devices drivers of I/O devices which it uses, within itself.
The usual technique is to divide the memory between the Operating System and Single User Processes. The operating system may occupy either RAM or ROM or the device drivers may be in ROM and rest of operating system may in RAM, which will enable only processed to run at a time.
The above method is used wither when working in single user environment or when there is only process to execute at a given time. But this method is really meaningless when we are working in multi user, Multi programming environments. For this we use another method.
For Processing Multiple Programs at a Time
For processing multiple programs in a memory, there are two techniques available out of which any one is used.
The following are the techniques which can be used for multi programming:
Fixed Partitioning of the Memory, Variable partitioning of memory (Relocation)
Fixed Partitioning of the Memory
This method involves dividing of the memory into many parts (may be of equal/unequal sizes). When there is a request for processing it can be allocating the smallest possible Partition of the memory which is sufficient for it.
With requests coming in they can be aligned either in Single Queue or Multiple Queues. Sorting the processes and assigning them separate queue becomes very difficult and even problematic as there can be partitions which may be free and others having long queues. Therefore some algorithm should go in, so that at every instance it checks free partitions and assigns them to suitable process in queue.
The following figures depict how the memory can be partitioned and how processes can be arranged in single queues and multiple queues, so that we can clearly see the Operation of Multiple Queues and Single Queues.
Variable Partitioning of Memory (Relocation)
The problem with fixed partitions of memory is that when a job comes which will not fit into any of the available partitions, and then the problem will arise. As well whenever the allocation of partition is made and another process comes in, even if the other partitions are free, it will not be able to gain the partition as it is already assigned to another process.
Therefore, the concept of variable partitioning of memory has been arrived at. This concept involves that instead of fixed partitions, wherever a process comes, the memory of the size which it requires, is allocating. The logic behind this is that when few processes are already running. If a new process comes in, these, already running processes can be relocated so that some memory is allocated the new incoming process. This process of relocation goes on n a cycle giving chance to any new in coming program to acquire memory.
Education of Memory Management by Swapping
When the program to be executed is very large to be accommodated in the memory, the problem of how to execute the program arises, as the program has to be in main memory to get executed. This problem is solved by the “Swapping Technique”. In this technique, a part of the program is loaded into main memory and other part is in secondary memory. After the execution of the part in memory it is sent back to secondary memory and that part of the program which is stored in Secondary Memory is loaded into the main memory. This process or moving programs from main memory to secondary memory and back is known as swapping.
This swapping not only helps to execute large programs but also aids multi programming, where parts of many programs are loaded into the main memory, as and when they get executed, they are swapped and next part or new programs are loaded into main memory. This can be done even with fixed partitions of the memory but the problem here is that when programs are small, then lot of Space in Memory Partition goes waste.
Therefore, usually variable partitions of memory are used, so that the memory is allocated depending on the size to various programs so that the Memory Space is utilized to the maximum level. The above sequence of figures depicts how the memory is allocated among various programs and how it is swapped as and when a new program comes for execution.