0% found this document useful (0 votes)
3 views

Module5FileSystemsImplementation-PPT

Uploaded by

94qb4tkfq9
Copyright
© © All Rights Reserved
Available Formats
Download as PPSX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Module5FileSystemsImplementation-PPT

Uploaded by

94qb4tkfq9
Copyright
© © All Rights Reserved
Available Formats
Download as PPSX, PDF, TXT or read online on Scribd
You are on page 1/ 22

Module-5

File System
Implementation
File System Implementation

File-System Structure

File-System Implementation

Directory Implementation

Allocation Methods

Free-Space Management

DR.BHAGYA JYOTHI K L,KVGCE


1: File-System Structure
File is a Logical storage unit & Collection of related information

Disk provides in-place rewrite and random access


◦ I/O transfers performed in blocks of sectors (usually 512 bytes)

File system resides on secondary storage (disks)


◦ Provides efficient and convenient access to disk by allowing data to be stored, located,
retrieved easily
◦ Poses two major problems: Provided user interface to storage, algorithms to map
logical to physical storage
File control block – storage structure consisting of information about a file
Device driver controls the physical device
DR.BHAGYA JYOTHI K L,KVGCE
DR.BHAGYA JYOTHI K L,KVGCE
Layered File System
Each File system is organized into layers
Each layer in the design uses the features of lower levels to create
new features for use by the higher levels

DR.BHAGYA JYOTHI K L,KVGCE


File System Layers
Device drivers manage I/O devices at the I/O control layer
Given commands like “ read block 6 ”
outputs low-level hardware specific commands to hardware controller

Basic file system issues commands like “retrieve block 123” to device
driver Also manages memory buffers and caches
Buffers hold data in transit
Caches hold frequently used data

File organization module understands files, logical address, and physical


blocks
Translates logical block # to physical block #
Manages free space, disk allocation

DR.BHAGYA JYOTHI K L,KVGCE


File System Layers (Cont.)
Logical file system manages metadata information
Maintains file structure by file control blocks
Directory management
Protection

Application Programs
 Written By Users
Layering useful for reducing complexity and redundancy, but adds
overhead and can decrease performance
Logical layers can be implemented by any coding method according to OS designer

DR.BHAGYA JYOTHI K L,KVGCE


File Allocation Methods
An allocation method refers to how disk blocks are allocated to files
There are mainly 3 types of Allocation Methods

1. Contiguous Allocation
2. Linked Allocation
3. Indexed Allocation

DR.BHAGYA JYOTHI K L,KVGCE


1. Contiguous Allocation
• In Contiguous Allocation each file occupies set of contiguous blocks
in the hard disk.
• Directory should contain the starting address of the block and
length(Number of blocks).

• Provides Best performance in most cases.


• Simple to implement– only starting location (block #) and length (number of
blocks) are required.
• Supports both sequential and direct access
• Problems include finding space for file, knowing file size, external fragmentation,
need for compaction off-line (downtime) or on-line

DR.BHAGYA JYOTHI K L,KVGCE


Contiguous Allocation
DR.BHAGYA JYOTHI K L,KVGCE
2. Linked
 Each file is a linked list of Disk blocks.
Directory should contain address of starting node and last node

File ends at null pointer


Each block contains pointer to next block
No compaction, external fragmentation
Free space management system called when new block needed
Improve efficiency by clustering blocks into groups but increases internal
fragmentation
Reliability can be a problem
Locating a block can take many I/Os and
DR.BHAGYA disk
JYOTHI seeks
K L,KVGCE
Linked Allocation

DR.BHAGYA JYOTHI K L,KVGCE


3. Indexed
◦ Each file has its own index block which contains pointers to its data blocks.
◦ Address of the index box is kept in Directory

DR.BHAGYA JYOTHI K L,KVGCE


Performance
1. Contiguous Allocation
 Requires only one access to get a disk-block
 We can calculate immediately the disk address of the next block and read it
directly
Good for direct access
2. Linked Allocation
 Good for sequential access
 Not be used for an application requiring direct access

3. Indexed Allocation
 If the index block is already in memory, then the access can be made directly
 Keeping the index block in memory requires considerable space
 Good for direct access
DR.BHAGYA JYOTHI K L,KVGCE
Free-Space Management
Managing the free blocks of hard disk in known as Free space management.
A free-space list is maintained to keep track of free disk-space (i.e. those not allocated
to some file or directory).
It contains the information about free blocks in the hard disk
During File creation
1. OS searches the free-space list for the required amount of space.
2. Allocate that space to the new file.
3. This space is then removed from the free-space list.
During file Deletion
Deleted file disk-space is added to the free-space list.

DR.BHAGYA JYOTHI K L,KVGCE


4 Techniques
There are mainly 4 techniques
1. Bit Vector
2. Linked List
3. Grouping
4. Counting

DR.BHAGYA JYOTHI K L,KVGCE


1. Bit Vector
The free-space list is implemented as a bit map/bit vector.
Each block is represented by a bit.
1. If the block is free, the bit is 1.
2. If the block is allocated, the bit is 0.

For example, consider a disk where blocks 2, 3, 4, 5 and 7 are free and the rest
of the blocks are allocated. The free-space bit map will be 00111101

Advantage: simplicity & efficiency

Disadvantages:
1. Inefficient unless the entire vector is kept in main memory.
2. The entire vector is written to discDR.BHAGYA
occasionally
JYOTHI Kfor recovery.
L,KVGCE
2. Linked List
1. Link all the free disk-blocks together as a List
2. Keep a pointer to the first free block in a special location on
the disk.
3. Cache that block in memory.

• The first block contains a pointer to the next free one, etc.

Advantage:
• Efficient

Disadvantage:
1. Not efficient, because to traverse the list, each block is read.

DR.BHAGYA JYOTHI K L,KVGCE


DR.BHAGYA JYOTHI K L,KVGCE
3.Grouping
 The addresses of first n free blocks are stored in the 1st free block.
 The last block contains addresses of another n free blocks, etc.
Advantage:
 Addresses of a large no of free blocks can be found quickly.

DR.BHAGYA JYOTHI K L,KVGCE


4. Counting

 Keep the address of the first free block and the number ‘n’ of free
contiguous blocks that follow the first block.
 Takes advantage of the fact that, generally, several contiguous
blocks may be allocated/freed simultaneously.
 Each entry in the free-space list then consists of a disk address and a
count.

DR.BHAGYA JYOTHI K L,KVGCE


END

You might also like