The next layer of the operating system is the Memory Management layer, responsible for sharing the physical memory of the computer between processes and handling programs which require more memory than physically available. This layer is also responsible for ensuring that the memory allocated to any program is protected against access by other programs.
Early PCs had only a few kilobytes of memory, but more recent machines have many megabytes and PCs with several gigabytes of memory are commonplace. However, no matter how large the memory, it is soon used up once we start running programs. Memory is a valuable system resource which must be carefully managed and shared between programs and processes in accordance with their requirements.
At its simplest, memory management consists of loading a program from disk and allowing it to use all the memory it wants. This happened in older single-user, single-tasking operating systems such as CP/M and MS-DOS. Later versions of these operating systems allowed more than one program to run simultaneously, so they needed basic memory management features to ensure that physical memory was shared equitably between them. However, if a program wanted more memory than was physically present or allocated to it, it could not proceed and would often crash.
We do not want any process to be able to access memory that is already in use by another program or by the operating system itself, so each memory segment is tagged with information about which process owns it, which others are permitted access and whether other processes can modify the contents or simply read data from it. Any attempt by a process to use a memory segment to which it has not been granted access will be prevented.
Modern operating systems generally support multi-user or multi-tasking operation. There is no effective limit on the number of programs that can run simultaneously, or to the amounts of memory each program may demand. No matter how much physical memory is available it will eventually be insufficient. It not acceptable to refuse the program the memory it needs, so some method must be devised to provide it. The solution is to use virtual memory.
Next: Virtual Memory