0% found this document useful (0 votes)
64 views11 pages

File System Impelementation

This document discusses different file system allocation methods and free space management techniques. It describes three major allocation methods - contiguous, linked, and indexed allocation. Contiguous allocation allocates files in contiguous blocks but can cause problems like fragmentation. Linked allocation solves these issues by linking non-contiguous blocks through pointers. Indexed allocation uses an index block to point to file blocks, addressing fragmentation and size declaration problems. The document also covers free space management using techniques like free space lists, bit vectors, linked lists, grouping, and counting.

Uploaded by

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

File System Impelementation

This document discusses different file system allocation methods and free space management techniques. It describes three major allocation methods - contiguous, linked, and indexed allocation. Contiguous allocation allocates files in contiguous blocks but can cause problems like fragmentation. Linked allocation solves these issues by linking non-contiguous blocks through pointers. Indexed allocation uses an index block to point to file blocks, addressing fragmentation and size declaration problems. The document also covers free space management using techniques like free space lists, bit vectors, linked lists, grouping, and counting.

Uploaded by

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

File System Implementation

Allocation Methods

• Allocation methods deal with allocation of


space to files so that the disk space is
utilized effectively and files can be access
quickly.
• Three major methods of allocating the
disk space are in wide use
• Contiguous allocation
• Linked allocation
• Indexed allocation
Contiguous Allocation
• Each file occupies a set of contiguous blocks on the
disk.
• Simple allocation method. Only starting location
(block#) and length (number of blocks) are required.
- For a file n blocks long and starts at location b, then it
occupies blocks b, b+1, b+2, …, b+n-1
- The directory entry for each block includes the
starting address of each block and the length
allocated for this file
• Contiguous allocation has some problems
• Dynamic storage-allocation
• External fragmentation
• Determining how much space is needed for a file
- Allocate too little and the file may not be extended
- Allocate too much and space is wasted
• To minimize these drawbacks, some operating systems use
a modified version -> initially a contiguous chunk space is
allocated and then, when that amount is not large enough,
another chunk, an extent is added to initial allocation.
Linked Allocation
• Solves all the problems of contiguous allocation
• Each file is a linked list of disk blocks: blocks may be
scattered anywhere on the disk
pointer
Block =
data

• The directory contains a pointer to the first and last


blocks of a file.
• No external fragmentation
• Any free block on the free-space list can be used to
satisfy a request
• A file can grow as long as free blocks are available, never
need to compact disk space
• Linked allocation does have disadvantages
– Only effective for sequential-access files
– Space required for the list pointers.
File Allocation Table
Indexed Allocation
• Solves the external-fragmentation and size-declaration problems of
contiguous allocation
• Supports direct access by bringing all the pointers together into the
index block
• Each file has its own index block, which is an array of disk-block
addresses

Index table
Indexed Allocation…

• Indexed allocation suffer from wasted space. If the


index block is too small, it will not be able to hold the
enough pointers for a large file.
• Indexed block can be handled in different ways.
• Linked Scheme
Index file
block block

lin
k

lin
k
Indexed Allocation…
• Multilevel index

outer-
index
index
table file

• Combined Scheme
Free Space Management
• Need to reuse the space from deleted files for new files
• To keep track of free disk space, the system maintains a
free-space list
– Stores all free blocks – those not allocated to a file or
directory
• To create a file the free-space list is searched and that
space is allocated to the new file, this space is then
removed form the list
• When a file is deleted its disk space is added to the free
space list
Bit Vector
• Frequently, the free-space list is implemented as a
bit-map or bit vector
– Each block is represented by 1 bit
– If the block is free; the bit is 1; if the block is allocated the
bit is 0
0 1 2 n-1
bit[i] =
{ 1 implies block[i] free

0 implies block[i] occupied

• Easy to get first free block or n consecutive free


blocks on the disk.
• Example BSD file system (used by Apple Macintosh)
• Bit Vector requires extra space
Free Space Management…
 Linked list (free list)
 Keep a linked list of free blocks
 Cannot get contiguous space easily, not very efficient
because linked list needs traversal.
 Grouping
 Keep a linked list of index blocks. Each index block
contains addresses of free blocks and a pointer to the
next index block.
 Can find a large number of free blocks contiguously.

 Counting
 Linked list of contiguous blocks that are free
 Free list node contains pointer and number of free
blocks starting from that address.
 The Overall list will be shorter.

You might also like