Q14. Illustrate File Allocation of Operating System
Q14. Illustrate File Allocation of Operating System
Answer: The allocation methods define how the files are stored in the disk blocks. There
are three main disk space or file allocation methods.
Contiguous Allocation
Linked Allocation
Indexed Allocation
1. Contiguous Allocation:
In this scheme, each file occupies a contiguous set of blocks on the disk. For
example, if a file requires n blocks and is given a block b as the starting location, then
the blocks assigned to the file will be: b, b+1, b+2…b+n-1. This means that given the
starting block address and the length of the file (in terms of blocks required), we can
determine the blocks occupied by the file.
The directory entry for a file with contiguous allocation contains
Address of starting block
Length of the allocated portion.
3. Indexed Allocation:
In this scheme, a special block known as the Index block contains the pointers to
all the blocks occupied by a file. Each file has its own index block. The ith entry in the
index block contains the disk address of the ith file block.
15. What is resource allocation graph? Write and explain its notation with the help of an
example.
Answer: As Banker’s algorithm using some kind of table like allocation, request,
available all that thing to understand what is the state of the system. Similarly, if you
want to understand the state of the system instead of using those table, actually tables
are very easy to represent and understand it, but then still you could even represent the
same information in the graph. That graph is called Resource Allocation Graph (RAG).
In RAG vertices are two type:
1. Process vertex: Every process will be represented as a process vertex
2. Resource vertex: Every resource will be represented as a resource vertex.
Example 1 (Single instances RAG):
If there is a cycle in the Resource Allocation Graph and each resource in the cycle provides only
one instance, then the processes will be in deadlock. For example, if process P1 holds resource
R1, process P2 holds resource R2 and process P1 is waiting for R2 and process P2 is waiting
for R1, then process P1 and process P2 will be in deadlock.
Example 2 (Multi-instances RAG):
Here’s another example, that shows Processes P1 and P2 acquiring resources R1 and
R2 while process P3 is waiting to acquire both resources. In this example, there is no
deadlock because there is no circular dependency.
So cycle in single-instance resource type is the sufficient condition for deadlock.