5.1 Memory Management
5.1 Memory Management
5.1 Memory Management
• For the Figure-1, we scan the bitmap sequentially for the first non-
zero word.
The first group of 8 bits (00001110) constitute a non-zero
word since all bits are not 0. After the non-0 word is found, we look
for the first 1 bit. This is the 5th bit of the non-zero word. So, offset
= 5.
Therefore, the first free block number = 8*0+5 = 5.
• Linked List –
In this approach, the free disk blocks are linked together i.e. a
free block contains a pointer to the next free block.
The block number of the very first disk block is stored at a
separate location on disk and is also cached in memory.
In Figure-2, the free space list head points to Block 5 which
points to Block 6, the next free block and so on.
The last free block would
contain a null pointer indicating
the end of free list.
• Advantages
1. If a file is to be allocated a free block, the operating
system can simply allocate the first block in the free space
list and move the head pointer to the next free block in the
list.
2. No disk fragmentation as every block is utilized.
• Disadvantages
1. It is not very efficient method as to traverse the
list, each block must be read, which requires substantial
I/O time.
2. Pointers used here will also consume disk space.
Additional memory is therefore required.
• Virtual Memory
• A computer can address more memory than the
amount physically installed on the system.
• This extra memory is actually called virtual
memory and it is a section of a hard disk that's set up
to emulate(compete) the computer's RAM.
• The main visible advantage of this scheme is that
programs can be larger than physical memory.
• Virtual memory serves two purposes.
1. First, it allows us to extend the use of physical
memory by using disk.
2. Second, it allows us to have memory protection,
because each virtual address is translated to a
physical address.
•
Following are the situations, when entire program is not
required to be loaded fully in main memory.
Solution:-
Reference String:-
Frames 7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1
1 7 7 7 2 2 2 2 4 4 4 0 0 0 0 0 0 0 7 7 7
2 0 0 0 0 3 3 3 2 2 2 2 2 1 1 1 1 1 0 0
3 1 1 1 1 0 0 0 3 3 3 3 3 2 2 2 2 2 1
Page Fault √ √ √ √ √ √ √ √ √ √ √ √ √ √ √