0% found this document useful (0 votes)
12 views8 pages

Internal Representation of Files - 5

Uploaded by

jesawid181
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)
12 views8 pages

Internal Representation of Files - 5

Uploaded by

jesawid181
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/ 8

Internal Representation of Files(5)

Inode assignment to a new file

Process A Process B Process C

Assigns inode I from


super block

Sleeps while reading


inode(a)
Tries to assign inode
from super block use
Super block empty(b) the
Search for free inodes on lock
disk, puts inode I in su-
per block (c)
Inode I in core
Does usual activ-
ity Completes search,
assigns another in-
ode(d) Assigns inode I from
super block
I is in use!
Assign another
inode(e)
Race Condition in Assigning
ifree
algorithm
Allocation of disk blocks
 When a process writes data to a file, the kernel must allocate
disk from the file system for direct data blocks and
sometimes for indirect blocks.
 The file system super block contains an array that is used to
cache the number of free disk blocks in the file system.
 The utility program mkfs organizes the data blocks of file
system in a linked list.
 Each link in the list contains the array of free disk block
numbers, and one array entry is the number of next block
of the linked list
 Kernel allocates the next available block in the super block
list
 If the allocated block is the last block in the super block
cache, the kernel treats it as a pointer to a block that
contains a list of free block numbers, and then proceeds to
use the original block number
 The algorithm for freeing a block Is the reverse of the one for allocating a block
 If the super block list is not full, the block number of the newly freed block is placed
on the super block list.
 If the super block list is full, the newly freed block becomes a link block; the kernel
writes the super block list into the block and rites the block to disk.
 Kernel then places the block number of the newly freed block in the super block list
Other file types

pipe
 fifo(first-in-first-out)
 its data is transient: Once data is read from a pipe, it cannot be read again, no deviation from
that order
 use only direct block
special file
 include block device, character device
 the inode contains the major and minor device number
 major number indicates a device type such as terminal or disk
 minor number indicates the unit number of the device
References

The design of Unix Operating System - Maurice J. Bach (PHI)

You might also like