Chapter No 5 Memory Management
Chapter No 5 Memory Management
Memory Partitioning
Free space management techniques
Paging
Virtual Memory
Page Replacement
Swapping concept
Memory Partitioning
Divide the memory into several parts each part called as partitions.
Memory allocation in case of multiprogramming environment.
Operating System keeps record of occupied as well as free memory.
When process enter into ready state, operating system check status of
partition.
Different scheduling algorithm for process to enter into system
Advantages
1. Useful for multiprogramming environment.
2. It is easy to access data from partitions.
3. Easy to access the partitions.
4. Partitions can be dynamic or fixed. This provide flexibility
Memory Partitioning Continue…
Memory partitioning types
1. Static memory partitioning
2. Dynamic memory partitioning
Memory Partitioning Continue…
Static memory partitioning (Fixed partitioning)
Fixed size
If process assigned to memory is less in size, then remaining space
cannot be used by any other process.
Disadvantage
1. Memory is wastage
2. Internal fragmentation
Memory Partitioning Continue…
Dynamic memory partitioning (Variable partitioning)
Partition is done based on requirement of process length or size of process is
called as dynamic memory partitioning.
Process in ready queue the OS checks for available enough size partition in
memory.
Partition is larger than required then partition is divided. Then process is kept
in appropriate part of memory and remaining partition of memory added in the
partition available list.
Example. Suppose we have a memory 128 MB out of that memory 32 MB
occupied by operating system remaining 96 MB memory of user process.
Dynamic memory partitioning (Variable partitioning) continue …
Dynamic memory partitioning (Variable partitioning) continue …
In this way many small partition get created, which may be very small in size.
This types of small partitions remain unutilized. This is known as external
fragmentation.
Advantage
1. Partitions are made as per the process length.
2. Memory wastage is very less.
3. Maximum part of memory is utilized
Disadvantage
1. External fragmentation
2. Compaction
Concept of Compaction
Compaction shuffles the free memory locations together in one
large block. Compaction is not always possible.
Concept of Compaction continue….
Free-space list
• Records all free disk blocks which is not allocated to some file or
directory.
• Space is removed- New file allocated space.
• Space is added – File is deleted.
Disk block 0 1 2 3 4 5 6 7 8 9 10
Bitmap 1 1 0 0 0 1 1 1 0 0 1
1.3 GB disk with 512 bytes blocks would need a bit map of over 332 KB to
track its free blocks.
1 TB disk with 4 KB blocks requires 32 MB to store its bit map.
1 PB file system would take 32-GB bitmap just to manage its free space.
Linked List
In linked list is to link together all the free disk blocks, keeping a
pointer to the first free block in a special location on the disk.
This first block contains a pointer to the next free block, and so on.
Example free block are 2,3,4,5,8,9,10,11,12,13,17,18,25,26 and 27
were free block and the rest of the blocks were allocated.
Keep a pointer to block 1 as the first free block, block 2 would
contain a pointer of block 3 and so on…
This scheme is not efficient; to traverse the list, we must read each
block, which requires substantial I/O time.
Example free block are 2,3,4,5,8,9,10,11,12,13,17,18,25,26 and
27 were free block and the rest of the blocks were allocated.
Base and Limit Registers
Base register: The base register holds the smallest legal physical
memory address
Limit register: The limit register specifies the size of the rang.
Fig. Hardware address protection with base and limit
register
Logical and Physical Address
4
1
3 2
4
Virtual-address Space
Shared Library Using Virtual Memory
Demand paging
Bring a page into memory only when it is needed
◦ Less I/O needed
◦ Less memory needed
◦ Faster response
◦ More users
Frame # valid-invalid bit
v
v
v
v
i
….
i
i
page table