0% found this document useful (0 votes)
33 views5 pages

Unit

Uploaded by

maincastle134
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views5 pages

Unit

Uploaded by

maincastle134
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Unit – 3(chapter – 4)

UNIT – V
Implementing File System
Directory Implementation:-
 The commonly used directory management algorithms are as follows:
(1) Linear List (2) Hash Table
1. Linear List:-
 This is the simplest Directory Implementation Method. It is easy to implement but it takes a
lot of time to execute.
 In this, searching a file requires a Linear search.
 To create a new file also linear search is required to verify whether file is already existing
with that name or not.
 Similarly a delete operation also requires a linear search for directory and then space is de
allocated.
 Instead of Linear Search, Binary Search technique can also used. Though it improves
average Search time, but still needs a sorted list of directory entries to search.
Advantage:-
 This approach is simple and easy to implement.
Disadvantage:-
 This method requires linear search for finding a file before performing any operation. This
makes it slow.
2. Hash Table:-
 In this technique a hash table is used only with the Linear list for Storing Directory entries.
 The hash table uses has function that takes an input value based on the file name and
produces an output as reference to the corresponding Directory entry in the Linear list.
Advantage:-
 Hash table is used to speed up searches.
Disadvantage:-
 Hash table is usually fixed size and the performance of the Hash function depends on the
size of the Hash table.
******************************************************************************
Allocation Methods:-
 Allocation means Assigning the Storage Space to file or Storing files in secondary Storage.
 The files should be allocated in such a manner so that disk space is utilized effectively and
files can be accessed quickly.
 These are 3 methods are used for allocating disk space to files. They are
(1) Contiguous Allocation
(2) Linked Allocation

1
Unit – 3(chapter – 4)
(3) Indexed Allocation
1. Contiguous Allocation:-
 In contiguous allocation method, each file occupies a set of contiguous blocks on the disk.
 All the block are continuously Kept together.
 There is an index that Specifies the Starting address and the length (size) indicating the
blocks.
 Contiguous Allocation is shown in the following fig:

File Allocation Table


File Start Length
name
Demo1 2 3
Demo2 9 5
Demo3 18 6

 The Different allocation strategies First – fit, Best – fit and worst – fit are used.
Advantages:-
1. It is simple to implement.
2. Performance is good because entire file can be read from the disk in a single operation
(because it is stored contiguously).
Disadvantage:-
 This technique suffers from external fragmentation.
2. Linked Allocation:-
 In Linked allocation, each data block contains the address of next block in the file.
 Linked Allocation is shown in the following fig.

File Allocation Table


File Start End Size
name
Demo1 1 23 5
------- ---- ---- ---
------ ---- ------ ----

2
Unit – 3(chapter – 4)
 The Directory entry (file allocation table) contains Single entry for each file and it contains
a file name, Pointer to the first and last block of the file. In the above example Demo file
consists of 5 blocks, starting at block1 and ending at block 23.
 Each block contains an address of the next block, similarly all the blocks are linked
together.
 The last block does not have a next block dress.
Advantages:-
1. The Major advantage is no external fragmentation with Linked Allocation.
Disadvantages:-
1. Linked allocation can be used effectively only for sequential files. It is inefficient to support
a direct access.
2. In order to find the nth block of a file, we must start at the beginning of that file and follow
the pointers until we get to the nth block.
3. Indexed Allocation:-
 In Indexed Allocation, the various pointers of different blocks of a file are stored in one
block called “Index block” .
 The directory entry or FAT contains a separate one level index for each file.
 The file index for a file is kept in a separate block, and the FAT contains the address of that
index block. It is shown in the following fig:
File Allocation Table
File Index
name block
Demo1 24
------- ----
------ ----

24

Advantages:-
1. It is the most popular form of file allocation. It Support both Sequential and direct access to
the file.
2. Any free block on the disk can be used for allocation.
3. It eliminates External fragmentation.
Disadvantages:-
1. If the Index block is small, It will not be able to hold enough pointers for a large file.
******************************************************************************

3
Unit – 3(chapter – 4)
Free Space Management:-
 Whenever a new file is created, it is allocated some space from the available free space on
the disk.
 The free space can be either the space on the disk that is never used for allocation or the
space left by the deleted files.
 The file System maintains a “free space list” that indicates the free blocks on the disk.
 To create a file, the free space list is searched for free space and the space is then allocated
to the new file. After that newly allocated space is removed from the free space list.
 Similarly, when a file is deleted, its space is added to the free space list.
 The various methods are used to implement free space list are as follows:
1. Bit Vector
2. Linked list
3. Grouping
4. Counting
1. Bit Vector:-
 It is also called as Bit Map and it is used to implement free space list. Each block of disk
represented by a bit.
 If the block is free its bit is set to 1. If block is allocated, the bit is O.
 Apple Macintosh operating system uses it map method to allocate disk space.
 Bit Map is shown in the following fig:
0 0 1 0 1 1 0 0 0 1
0 1 1 1 0 0 0 0 1 1
1 1 1 1 0 1 1 0 0 0
 It is simple method for contiguous, Linked and Indexed allocation.
2. Linked list:-
 This method creates a linked list of the free blocks on the disk.
 The first block contains a pointer to next free block, which contains a pointer to next free
block and so on. The first free block in the list can be pointed out by a head pointer.
 Linked list method for free space list is shown in the following fig:

4
Unit – 3(chapter – 4)
 In the above figure the Head pointer represent block 2, and which points to block 4, which
points to block 5 and So on.
 The limitation with this method is, it requires additional Space because it requires more
disk space to store a pointer.
3. Grouping:-
 It is the modified version of Linked list Method. Here a group of free blocks are linked
together.
 In each group the last block contains the address of next group of free blocks.
 Memory can be allocated in chunks of blocks. It is shown in the following fig:

 The Major advantage of this approach is that the addresses of free disk blocks can be found
with only one disk access.
4. Counting:-
 This Method can be used for allocate or free several contiguous blocks at the same time.
 This method keeps the address of the first free block and counts the number of ‘n’ free
contiguous blocks that follows the first block. It is shown in the following fig:

File Space Table

Starting Count
block
number
5 5
13 2
18 1

 Free space table contains disk address and a count of the block.
************************************************************************************

You might also like