Notes OS
Notes OS
Bitmap
A bit vector is the most frequently used method to implement the free space list. A bit
vector is also known as a "Bit map"
. It is a series or collection of bits in which each bit represents a disk block. The
values taken by the bits are either 1 or 0. If the block bit is 1, it means the block is
Notes OS 1
empty and if the block bit is 0, it means the block is not free. It is allocated to some
files. Since all the blocks are empty initially so, each bit in the bit vector represents 0.
1. The operating system goes through all the blocks until it finds a free block. (block
whose bit is 0).
Linked List :
A linked list is another approach for free space management in an operating
system. In it, all the free blocks inside a disk are linked together in a "linked list".
These free blocks on the disk are linked together by a pointer. These pointers of the
free block contain the address of the next free block and the last pointer of the list
points to null which indicates the end of the linked list. This technique is not enough
to traverse the list because we have to read each disk block one by one which
requires I/O time.
2. As there is no size limit on a linked list, a new free space can be added easily.
Disadvantages :
2. the Linked list is not efficient when we need to reach every block of memory.
Grouping :
Notes OS 2
The grouping technique is also called the "modification of a linked list
technique". In this method, first, the free block of memory contains the addresses of
the n-free blocks. And the last free block of these n free blocks contains the
addresses of the next n free block of memory and this keeps going on. This
technique separates the empty and occupied blocks of space of memory.
1. By using this method, we can easily find addresses of a large number of free
blocks easily and quickly.
Disadvantage :
Counting :
In memory space, several files are created and deleted at the same time. For which
memory blocks are allocated and de-allocated for the files. Creation of files occupy
free blocks and deletion of file frees blocks. When there is an entry in the free space,
it consists of two parameters- "address of first free disk block (a pointer)" and " a
number 'n' ".
Advantages :
Disadvantage :
1. In the counting method, the first free block stores the rest free blocks, so it
requires more space.
Conclusion
File management system in an operating system is used to keep track of free
spaces to allocate and de-allocate memory blocks to files.
These space blocks are manipulated when there is a creation or deletion of a file
in our system.
Notes OS 3
Q.2 - Explain File Allocation Methods in details.
Ans: Whenever a hard disk is formatted, a system has many small areas called
blocks or sectors that are used to store any kind of file. File allocation methods are
different ways by which the operating system stores information in memory blocks,
thus allowing the hard drive to be utilized effectively and the file to be accessed.
Below are the types of file allocation methods in the Operating System.
Assuming a file needs 'n' number of blocks in the disk and the file begins with a
block at position 'x', the next blocks to be assigned to it will be x+1,x+2,x+3,...,x+n-
1 so that they are in a contiguous manner.
Notes OS 4
There is a minimum amount of seek time.
Disadvantages
Due to its constrained allocation, it is possible that the disk would fragment
internally or externally.
The memory is not needed in contiguous form, it is more flexible than contiguous
file allocation.
Disadvantages
Notes OS 5
If pointers are affected so the disk blocks are also affected.
Disadvantages
It is possible that a single index block cannot keep all the pointers for some large
files.
1. Linked scheme
2. Multilevel Index
3. Combined Scheme
Notes OS 6
Q.3 - Explain Disk Structure and Disk Scheduling Algorithms in
Details
1. Seek Time: As we know, the data may be stored on various blocks of disk. To
access these data according to the request, the disk arm moves and find the
required block. The time taken by the arm in doing this search is known as "Seek
Time".
Notes OS 7
3. Transfer Time: When a request is made from the user side, it takes some time
to fetch these data and provide them as output. This taken time is known as
"Transfer Time".
4. Disk Access Time: It is defined as the total time taken by all the above
processes. Disk access time = (seek time + rotational latency time + transfer
time)
5. Disk Response Time: The disk processes one request at a single time. So, the
other requests wait in a queue to finish the ongoing process of request. The
average of this waiting time is called "Disk Response Time".
Advantages:
Notes OS 8
1. Implementation is easy.
2. No chance of starvation.
Disadvantages:
2. Not so efficient.
Advantages:
Disadvantages:
Advantages:
1. Implementation is easy.
Disadvantage:
1. The head keeps going on to the end even if there are no requests in that
direction.
Notes OS 9
4. C-SCAN disk scheduling algorithm:
It stands for "Circular-Scan". This algorithm is almost the same as the Scan disk
algorithm but one thing that makes it different is that 'after reaching the one end and
reversing the head direction, it starts to come back. The disk arm moves toward the
end of the disk and serves the requests coming into its path. After reaching the end
of the disk it reverses its direction and again starts to move to the other end of the
disk but while going back it does not serve any requests.
Advantages:
Disadvantages:
1. The time taken by the disk arm to locate a spot is increased here.
Advantages:
2. Since the head does not go to the end of the disk, the time is not wasted
here.
Disadvantage:
Notes OS 10
starts moving to the initial position. But in moving back, it does not serve any
requests.
Advantages:
2. If there are no requests till the end, it reverses the head direction
immediately.
4. The time taken by the disk arm to find the desired spot is less.
Disadvantage:
Conclusion:
The Disk Scheduling Algorithm in OS is used to manage input and output
requests to the disk.
Notes OS 11