Download as pdf or txt
Download as pdf or txt
You are on page 1of 13

Unit-II

Memory Management
Memory Management Techniques
[1]Fixed Partitioning:
• Memory is divided among number of static partitions at system generation time.
• Process may load in exactly same size or higher size partition. 10MB

• It is divided into two categories : 10MB

(a) Equal Size: - All partitions of same size. For example


10MB

10MB

10MB

10MB
• It leads to several disadvantages:

(i) If program is too big to fit into a partition, programmer must design the program
with overlay technique so only portion of program is required in main memory at a
time.

(ii) Main memory utilization is inefficient. Any program no matter how small it
occupies an entire partition. Internal Fragmentation problem will occur. Internal
Fragmentation means wastage of space due to fact that block of data that is loaded is
smaller than partition size.
(b) Not Equal Size: - All partitions are of not same size. For example
2 MB

3 MB

7MB

10MB

12MB

15MB
[2]Dynamic Partitioning:
• Partitions are of variable length and number and process is allocated exactly
as much memory as required.
• From time to time memory becomes fragmented and as a result external
fragmentation will occur. External Fragmentation is wastage of space due to
external partitions.
• It can resolve using compaction. According to compaction OS moves
processes so that they are contiguous in location but it is time consuming
and wastes CPU time.
[3]Paging :
• Partition memory into small equal fixed size chunks and divide each process into the
same size chunks.
• The chunks of a process are called pages
• The chunks of memory are called frames
Operating system maintains a page table for each process
• Contains the frame location for each page in the process
• Memory address consist of a page number and associated frame numbers.
A0
A1
A2
A3
D0
D2
D3
C0
C1
C2
C3
D4
D5
[4] Segmentation :
A program can be divided among number of segments that are not necessarily of same size.
However there is a maximum length of segment.
Operating system maintains a segment table for each process that consists of segment number
and offset.
• Segmentation is visible to the users.
• Segmentation is similar to dynamic partitioning but it differs in two ways than dynamic
partitioning.
• (a) In dynamic partitioning process requires contiguous allocation of space while in segmentation it
does not require that process is allocated in contiguous space.
• (b) In dynamic partitioning process occupy in single partition while in segmentation process may
occupy more than one partition.
Virtual Memory
• Memory management scheme in which secondary memory can act as a part of main
memory.
Resident Set :- Portion of process that is reside in main memory

Why virtual memory is required?

• (1) More processes may be maintained in main memory: - According to virtual memory it is
not necessary to load entire process so more processes may be maintained in main memory.
• (2)Help in execution larger process than main memory:- If any process is larger than main
memory, only portion of process is required in main memory according to virtual memory so that
process is able to execute.
Operating System Policies for Virtual Memory
(1) Fetch :- Determines when a page should be brought into memory. Demand paging only brings pages
into main memory when a reference is made to a location on the page. Prepaging brings in page before its
demand.

(2)Placement Policy:- Determines where in real memory a process piece is to reside. There are three
main alternatives for that.

 Best Fit :- Chooses the block that is closest in size to the request.
 First Fit :- Scans memory form the beginning and chooses the first available block that is large enough.
 Next Fit :- Scans memory from the location of the last placement and chooses the first available block
that is large enough.
(3) Replacement Policy :- Determines which page is replaced. There are three
main replacement policies :

(1) Optimal :- Selects for replacement that page for which the time to the next reference is
the longest. Impossible to have perfect knowledge of future events.

(2) LRU :- Replaces the page that has not been referenced for the longest time.

(3) FIFO :- Replace the page in First In First Out manner.

You might also like