One function of an operation
system is to manage the memory in efficient manner. The part
of the ( memory manager ) operation system, that manages the memory is called
memory manager. The job of the memory
manager is
1) It maintains
the list which parts of the memory are in use and which parts are
in not used.
2) It allocates the
memory to a process if requires.
3) Deallocates the
memory when the process is complete.
4) It manages
swapping between main memory and secondary memory.
Main Memory
Allocation : The main memory is divided
into number of consecutive locations regions. Each region can store a
block of information. The process of finding a region of the
main memory to which a particular block of information ( process
and program ) is assigned is called main memory allocation.
The
information needed for memory allocation is maintained by the
operation system in the memory map the memory map contains the following
information.
1)
Memory occupied space list which specifies the block name,
block size and its base address of
the region.
2)
Memory available space list which includes the address
of the unused portion of the memory and its size.
3) A secondary memory directory which
contains secondary memory devices and directries for all the
devices.
4) When a block is
transferred from secondary to the main memory the operation system makes
an entry in the occupied space list. When a block is no
longer requires in the main memory it is reallocated and the region
it occupies is transferred from occupied space list to the available
space list.
Memory Management
Schemes: Memory management
plays an important role in the operation system. The
different memory management schemes are
1) Single Continuous allocation.
2) Partitioned allocation.
3) Relocatable partitioned allocation.
4) Paged allocation.
5) Demand paged allocation.
6) Segmented allocation.
7) Segmented paged allocation.
In the above example address space
of Job1 is divided into two pages. Job2 is divided into three pages
and Job3 consist of only one page we are assuming each page size is
1000B there is a page map table for each Job which consists of
page. Number and the location of that page in the memory, there is
mapping that takes place with each address i.e.., each address in the
Job's address space can be transferred into an address in the physical
memory.
In the above example a Job may not be a
multiple of 1000B long. Then a portion of last page of that Job will be
wasted. This is called Internal Fragmentation.
Advantages :
1) It
solves the fragmentation problem without physically moving the pages in the
memory.
2) This
allows a higher degree of multiprogramming.
3) The compaction in relocatable portioned
allocation is eliminated.
Disadvantages
:
1) Page Address
mapping hardware increase the cost of the computer system.
2) Extra cost or
extra registers needed for page map tables.
3) There is a
possibility of internal fragmentation (or) page breakage may occur.
4) Some memory will still unused if the
number of available page frames are not sufficient for the
Job's page.
Single Continuous
Allocation : On this type of
memory management scheme usually the operating system
(monitor) is resides in either upper part or lower part of the main
memory. A single job is assigned to all the part of the portion of the memory
although, it requires a small portion. The job is controlled by the CPU
until it is completed an error occurs. The CPU is ideal in the system at
time of I/O operations, this type of memory allocation is used for small in
expensive completing system.
Dis-advantages
:
1)
A single job is assigned to all the memory so large amount of
memory may be wasted.
2) CPU
time is wasted.
3)
In this scheme the resources are not utilized in
efficient manner at the same time there is not enough hardware
flexibility to allow effective allocation of memory.
Partitioned
Allocation : To solve the problems of CPU
wasted time and wasted memory the partitioned allocation scheme was
introduced. In this memory is partitioned. This scheme is used and
systems with MFT ( Multi programming with Fixed number of Tasks)
and MVT ( Multi programming with
Variable number of Tasks). Multi programming means
maintaining the concurrent execution of more than one program by single
CPU.
In Multiprogramming partitioned scheme the CPU time
is allocated to each job or a Time-Slice priority basis. For a
time-slice ( say 100 ms) the CPU executes a program until one of the
following conditions occur.
1. Job list completed.
2. Error is detected.
3.
I/O is required.
4. Jobs Time-Slice is over.
In
the first two cases the job can be removed from the memory. In the
last two, the job is only temporarily suspended, it is to be
resumed. In each case the CPU is then assign to the job with next highest
priority.
Advantages
:
1)
Multiprogramming eliminates the CPU wasted time.
2)
With partitions the memory wastage is reduced.
Disadvantages
:
1) The
major problem with a partitioned allocation once
is fragmentation.
2)
Fragmentation is the development of unused 20k regions called fragments in the
memory. Fragmentation is shown in figure.