Memory Management
In a uni-programming system , the main memory
is divided into two parts , one for the operating
system ( kernel)
The other part for the program currently running
In multi programming system , the user part of the
memory must be divided among several
processes.
This task of subdivision is done dynamically by
the operating system and it is known as Memory
Management
Memory Management Requirements
Basic Hardware
Address Binding
Dynamic Loading
Dynamic Linking
Logical and Physical address space
Over lays
Basic Hardware
The CPU can only access its registers and main
memory
Eg:
Make direct access to hard drive, so any data stored
must be transferred into main memory
Memory access to main memory are comparatively
slow , and may take number of clocks ticks to
complete , this leads to long waiting by the CPU
which is resolved by fast memory cache
The basic idea of cache is to transfer the chunks of
memory and then to access individual memory
locations one at a time
The memory is usually implemented by using base
register and limit register for each process
The base register holds the smallest allowed physical
memory address
The limit register(known as Fence register) holds the
range
Every memory access made by the user is checked
against two registers, if memory access is attempted
outside the valid range a fatal error is generated
The os has access to all memory locations , as it is
necessary to swap users code and data is out of memory
The base and limit register can be loaded only by thee OS
Changing the content of base and limit registers is again
privileged activity allowed only to OS kernel
Address binding
Address binding relates how the code of a program is
stored in memory
Programs are written in human readable text following by
the series of rules and using keywords that are interrupted
to action by the computer’s CPU
Some programs like C and Cobol need to be compiled
while others run the original program text rather than a
machine code compiled in binary version
Compile Time
This is the first type of address binding
This allocates a space in memory to the machine code
when the program is compiled to the executable binary
file
The address binding allocates to the logical address to
the starting point memory where the object code is stored
Load Time
If the memory allocation is designed at the time the
program is allocated , then no program can ever transfer
from one computer to another in its c compiled state
In the instance , the program’s logical address are bound
to physical address until the program is invoked and
loaded into the memory
Execution time
If the process is moved from one segment to another
segment during its execution the binding must be
delayed until run time .
Most of the general purpose operating system use this
method . The below fig shows the various stages of
binding processes and the units involved in each stage
Dynamic Loading
In dynamic loading a program or a routine is not loaded
until it is called
All routines are stored on the disk in a relocatable load
format
The main program is first loaded into memory and
executed
When a routine wants to call another routine , the
calling routine first checks to see whether that routine
has been loaded
Next control is passed to newly loaded routine
Dynamic Linking
Linking postponed until execution time
Small piece of code , stub , used to locate the appropriate
memory resident library routine
Stub replaces itself with the address of the routine , and
executes the routine
Operating system needed to check if routine is in
processes memory address
Dynamic linking is particularly useful for libraries
System also known as shared Libraries
Logical and Physical address Space
An address generated by CPU is called Logical
address whereas the address generated by memory
unit is referred as physical address
The logical address is known as virtual address
Addresses bound at compile time or load time have
identical logical and physical address
Logical and physical address are same in compile
time and load time address binding schemes
Logical and physical address differ in execution
time binding schemes
Overlays
Keep in memory only those instructions and data
that are needed at any given time
Implemented by user no special support needed
by operating system
Programming design of overlay structure is
complex