Unit 4 Memory Management
Unit 4 Memory Management
Memory Management
Principle of Concurrency
• Criteria of performance-
1. Size
2. Access Time
3. Cost
Secondary
CPU Registers Cache RAM
Memory
Locality of Reference
• Locality of reference refers to the tendency for a program to access a small portion of
its memory at any given time, while the vast majority of its memory remains unused.
There are two types of locality of reference-Temporal and spatial.
• Spatial – it says if CPU need some instruction from MM then there are maximum
chances that next demand will be near by, therefore copy whole block in cache.
• Temporal –refers to the tendency for a program to access recently used memory
locations repeatedly. This means that if a program accesses a memory location , it is
likely to access that same location again in the near future.
Access Time
1. Contiguous Allocation
1. Fixed size partition
2. Variable size partition
2. Non Contiguous allocation
Memory Allocation
1. Contiguous Allocation
Allocation will be sequential at time. Left space cannot be reused.
It can be of two type-
a. Fixed partitioning – Memory is divided in fixed size partitions. Size of partition cannot
be changed. One partition can store only one process. it is again of two type-
i. Equal size
ii. Unequal size
Allocation can be contiguous only.
Disadvantage – Internal fragmentation, if size of process is not matched then process cannot be allocated.
Memory Allocation
1. Contiguous Allocation
a. Variable Size partitioning –
i. As the process will come space will be allocated
ii. Initial memory is available as single chunk
1. Contiguous Allocation
Allocation methods
1. First fit
2. Next fit
3. Best fit
4. Worst fit
Address Translation- Contiguous Allocation
CPU-
Limit Register-
Relocation Register-
Non-Contiguous Allocation
Paging-
• Paging is a storage mechanism used to retrieve processes from the secondary
storage into the main memory in the form of pages.
• The main idea behind the paging is to divide each process in the form of
pages. The main memory will also be divided in the form of frames.
• One page of the process is to be stored in one of the frames of the memory.
The pages can be stored at the different locations of the memory.
• Pages of the process are brought into the main memory only when they are
required otherwise they reside in the secondary storage.
Paging
Paging
Paging (Address Translation)
• When a page is to be accessed by the CPU by using the logical address, the
operating system needs to obtain the physical address to access that page
physically.
• The logical address has two parts -Page Number, Offset.
PNO offset
Q1. Calculate memory size where one address is of 14bits and one location is
of 1 byte.
Q2. Memory size if 64KB and memory is 2 byte addressable.
a) How many locations are there in memory?
b) How many address bits are required to represent address?
Paging (Address Translation)
Q2. There are four process P1, to P4 stored in Virtual Memory. P1 process takes 2 pages
{1,4}, P2{3,5,6}, P3{2,7} and P4{0,8,9,10}. Each page can contain 5 instructions. The
number of frames in MM are 5 in which 2nd frame is busy. CPU has demanded P2 process
10th instruction and P4 process 4th instruction. Design address mapping diagram with
proper data structures and addressing.