Memory management is a part of the operating systems that is responsible for efficiently sharing the main memory between all the process to help them execute as soon as possible. Any mechanisim and policiy associated with memory management in OS must satisfy some requirements. Some of these conditions are explained below.
Relocation
The main memory is shared along many processes that are running at the same time in multiprogramming systems. It is difficult to know where these process are stored in the memroy as it could be possible that one part of the same process is stored differently on some other place that the rest of the process in the memroy. In addition to this the process are swapped in and out of the memory by the operaing systems in order to increase the utulization of the CPU. The process that is swapped out of the memory is later reswapped in the memory and this time it could have had some other place in the memroy that is not related to it previous place in the memory.
The OS must know where the process is swapped back in into the memory and also the process control information as well about the execution stack of the process in order to complete its execution. It also requires the entry point to the process to begin execution in the memory, memory references in the program etc. The OS is responsible for translating the memroy refrences of the program into actual physical addresses. This translation of references into actual physical memory addresses in the memory is called relocation.
Protection
In multiprogramming systems, there are multiple processes that are executing at the same time. Each of these process must be protected from unwanted interference from some other process. No process should be allowed to refernece any memroy address of some other process without any necessary permissions.
A user process normally cannot access any part of the operating system. At normal conditions a process cannot access any other process data and memory instructions. CPU will not execute these instructions. That is why the protection requirement of the memory management must be satisfied by the processor and not the OS.
Sharing
The memory protection is also relaxed in some places. For example in some cases there could be running some programs that may be running same processes again and again. The memory is used more efficiently if the same copy of the program code is used. This type of the sharing is always done automatically by the system software.
The processes that cooperate to solve a problem need to share data. In order to share data between each other they must explicitly declare shared memory segments. The OS is responsible for protecting the shared data from unauthorized access by other process. It also ensures that the shared processes must not access other addresses that are not related to thier execution.