View
2.426
Download
0
Category
Preview:
DESCRIPTION
Citation preview
http://raj-os.blogspot.in/ 1
Free Space Management
http://raj-os.blogspot.in/ 2
HOME PREVIOUS TOPIC NEXTPREVIOUS QUESTION PAPERS FOR OSCPP TUTORIALS
http://raj-os.blogspot.in/ 3
Recap
In the last class, you have learnt:
• Secondary memory, types of secondary memory
• Various types of heads, advantages of one over other
• Techniques for increasing storage capacity
• Characteristics of the disk
http://raj-os.blogspot.in/ 4
Objectives
On completion of this period, you would be able to
know
• Need for free space management
• Various implementations of free space lists
• Bit vector, Linked list, Grouping, Counting
http://raj-os.blogspot.in/ 5
Understand Free Space Management
• Need for free space management
– Limited amount of disk space
– Necessary to reuse the space from deleted files
http://raj-os.blogspot.in/ 6
Need for Free Space Management
• To keep track of disk space :
– The system maintains a free space list
– The free space list records all disk blocks that are free
http://raj-os.blogspot.in/ 7
File Creation & Deletion
• File creation
– Search the free space list of the required amount of space
– Allocate the space to the new file
– Remove the space from free space list
• File deletion
– Add the disk space to the free space list
http://raj-os.blogspot.in/ 8
Various Implementations of Free Space List
• Bit Vector
• Linked List
• Grouping
• Counting
http://raj-os.blogspot.in/ 9
Bit Vector
• Free space list is implemented as a bit map or bit vector
• If the block is free the bit is set to 1
• If the block is allocated the bit is set to 0
http://raj-os.blogspot.in/ 10
Bit Vector
• Example:
– Consider a disk, where blocks
2,3,4,5,8,9,10,11,12,13,17,18,25,26 & 27 are free
and the rest of the blocks are allocated
– The free-space bit map would be
– 001111001111110001100000011100000……
http://raj-os.blogspot.in/ 11
Bit Vector (n blocks)
…0 1 2 n-1
bit[i] =0 block[i] free
1 block[i] occupied
Block number calculation
(number of bits per word) *(number of 0-value words) +offset of first 1 bit
http://raj-os.blogspot.in/ 12
• Bit map requires extra space
Example:
– Disk Size = 1.3 GB
– Block size = 512 bytes
– Need a bit map of over 332 KB to track its free
blocks
Bit Vector
http://raj-os.blogspot.in/ 13
Bit Vector
• Advantage:
– Relatively Simple and Efficient
– Easy to get contiguous files
http://raj-os.blogspot.in/ 14
Linked List
• Approach
– Link all free disk blocks together
– Keep a pointer to the first free block
– This block contains a pointer to next free block, and so on
14
http://raj-os.blogspot.in/ 15
Linked Free Space List on Disk
Example:
• As shown in figure in the next slide, there is a
• Pointer to block 2, as the first free block
• Block 2 would contain a pointer to block 3,
• Which would point to block 4,
• Which would point 5,8,9,10,11,12,13,17,18,25,26,27
15
http://raj-os.blogspot.in/ 16
Linked free space list on disk Fig 1
16
http://raj-os.blogspot.in/ 17
Linked List
• Linked list (free list)– Cannot get contiguous space easily
– No waste of space
– Not efficient for faster access
– Substantial I/O
17
http://raj-os.blogspot.in/ 18
Grouping
• Approach
– Store addresses of n free blocks in the first free
block
– The first n-1 of these are actually free
– The last block contains the address as of another
free blocks, and so on as shown in the next slide
Fig : 2
18
http://raj-os.blogspot.in/ 19
Grouping
Block No
.
Block No
.
.
Block No
Block No
.
Block No
Block No
Block No
.
.
.
Block No
Block No
. . .
First Free block Fig 2
19
http://raj-os.blogspot.in/ 20
Grouping
• Advantage
– Large number of free blocks can be found quickly
20
http://raj-os.blogspot.in/ 21
Counting
• Approach
– Based on the fact that several contiguous blocks may
be allocated and freed simultaneously
– Holds the address of the first free block and number
“n” of free contiguous blocks that follow the first
block
– Each entry is the free space list consist of a disk
address and a count21
http://raj-os.blogspot.in/ 22
Counting
• Entry in a free space list consists of
– Disk address
– Count
22
http://raj-os.blogspot.in/ 23
Counting
Constraints:
• Each entry requires more space than a simple
disk address
• The overall list will be shorter, as long as the
count is greater than one
23
http://raj-os.blogspot.in/ 24
Summary
In this class, you have learnt:
• What is free space management
• Various free space management techniques
24
http://raj-os.blogspot.in/ 25
Frequently asked questions
1. Explain the need for free space management
2. List the various implementations of free space list
3. Explain bit vector
25
http://raj-os.blogspot.in/ 26
Frequently Asked Questions
4. Explain the following free space management techniques
a) linked list
b) Grouping
c) Counting
5. Write the advantages and disadvantages of linked list method
of free space management
26
http://raj-os.blogspot.in/ 27
Quiz
• To keep track of disk space the system maintains
• Bit map requires extra space [T/F]
Free space list
True
http://raj-os.blogspot.in/ 28
Quiz
• In Linked allocation it is easy to get the contiguous space [T/F]
• In Counting it is easy to get the contiguous space [T/F]
False
True
28
Other subject materials
• Web designing
• Micro processors
• C++ tutorials
• java
home
29http://raj-os.blogspot.in/
Recommended