Basic Memory Management Requirements/Principles/Mechanism in Operating System

Any mechanism and policy associated with memory management should satisfy certain IT Services St. Louis requirements. Different requirements are as follows:

1. Relocation:
When a translator (compiler, interpreter, or assembler) translates a source code program into object code, it has no idea where the code will be loaded when the program is run. In fact, it may occupy a different area of memory each time it is run.

A programs will possibly be swapped in and out of memory. They may occupy different physical address locations at different, times. The translator cannot assign absolute physical addresses to instructions and data values in programs. But once the program code and data are loaded, processor and operating system must be able to reference the actual physical addresses. Relocation is a process of converting logical address to physical address.

2. Protection:
Program address space includes process control information (PCB), program code, data segment (global data), and stack/heap space. This information may or may not be stored in contiguous locations but it can be visualized as a linear sequence of addresses.

Operating System must protect the address space of one process from unauthorized access by other processes. No process should be allowed to access kernel code or space. When address space is stored contiguously, protection is relatively easy to achieve.

Protection must be provided by the hardware not the operating system. There is no way to tell in advance which addresses a program might reference as it runs. Dynamic calculation of array subscripts, pointers, etc. is only done at execution time.

3. Sharing:
Under certain circumstances, memory protection must be relaxed. In some situation, several processes are executing the same program such as an editor. The memory is used more efficiently if each process uses the same copy of the program code. This kind of sharing is almost always done automatically by the system software.

Processes that cooperate to solve a problem (for example, the producer-consumer problem) may want to access shared data structures. The processes that will participate in the sharing must declare shared memory segments explicitly. The operating system is responsible for protecting the shared memory from unauthorized access by other processes. It must also make sure that the sharing processes are restricted to the shared portion of each other’s address space.

4. Program Translation and Address Spaces:
A process has a logical address space. It is a linear set of locations that encompass the program code, variables, stack, etc. As the program executes, all or part of the logical address space is mapped to a physical address space. Physical address space is a subset of primary memory. The address space is a product of the translation-linking-loading process.

Translators generate re-locatable object code modules from source code. The various modules are then joined together (linked) to form a single module called load module. It is then loaded to memory.

At some point in time, the addresses produced by the ‘translator must be converted to physical addresses. This process is called address binding. Addresses can be bound at compile time (rarely), load time, or run time. The most common binding time in modern systems is run time.