|
What is memory management?
In a uni-programming system, main memory is divided into two parts: one part for the operating system (resident monitor, kernel) and one part for the program currently being executed. In a multi-programming system, the “user” part of the memory must be further subdivided to accommodate multiple processes. The task of subdivision is carried out dynamically by the operating system and is known as memory management.
Need for memory management
There are several requirements that memory management is intended to satisfy. These are:
- Relocation
- Protection
- Sharing
- Logical Organization
- Physical Organization
Relocation
In a multi programming system, the available main memory is generally shared among a number of processes. Typically it is not possible for the programmer to know in advance which other programs will be resident in main memory at the time of execution of his or her program. In addition, you would like to be able to swap active processes in and out of main memory to maximize processor utilization by providing a large pool of ready processes to execute. Once a program has been swapped out to disk, it would be quite limiting to declare that when it is next swapped back in, it must be placed in the same memory region as before. Instead we may need to relocate the process to a different area of memory.
Protection
Each process should be protected against unwanted interference by other processes whether accidental or intentional. Thus, programs in other processes should not be able to reference memory locations in a process for reading or writing purposes without permission. Fortunately, the mechanisms that support relocation also support protection requirement.
Normally, a user process cannot access any portion of the operating system, neither program nor data. Again, usually a program in one process cannot branch to an instruction in another process. Without special arrangement, a program in one process cannot access the data area of another process. The processor must be able to abort such instructions at the point of execution.
The memory protection requirements must be satisfied by the processor rather than the operating system. This is because the operating system cannot anticipate all of the memory references that a program will make. Thus it is only possible to assess the permissibility of a memory reference at the time of execution of the instruction making the reference. To accomplish this, the processor hardware must have that capability.
Sharing
Any protection mechanism must have the flexibility to allow several processes to access the same portion of main memory. If a number of processes are executing the same program, it is advantageous to allow each process to access the same copy of the program rather than have its own separate copy. The memory management system must therefore allow controlled access to shared areas of memory without compromising essential protection.
Logical Organization
Almost invariably, main memory in a computer system is organized as a linear, or one-dimensional, address space consisting of a sequence of bytes or words. Secondary memory, at its physical level, is similarly organized. While this organization closely mirrors the actual machine hardware, it does not correspond to the way in which programs are typically constructed. Most programs are organized into modules, some of which are un-modifiable and some of which contain data that may be modified. If the operating system and computer hardware can effectively deal with user programs and data in the form of modules of some sort, than a number of advantages can be realized. Segmentation is one such memory management technique which satisfies to all the above needs.
Physical Organization
Complete memory is organized into at least two levels, referred to as main memory and secondary memory. Main memory provides fast access at relatively high cost. In addition, main memory is volatile, that is, it does not provide permanent storage. Secondary memory is slower and cheaper than main memory and is usually not volatile. Thus secondary memory of large capacity can be provided for long term storage of programs and data, while a smaller main memory holds programs and data currently in use.
In this two level scheme, the organization of the flow of information between main and secondary memory, being a system responsibility is one among the most important issues tackled by Memory Management.
|