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

Chapter 2 - File System Management

Chapter 8 discusses file systems, focusing on free space management, file attributes, and file operations. It covers various allocation methods such as contiguous, linked, and indexed allocation, detailing their advantages and disadvantages. Additionally, it explains directory structures and the importance of maintaining efficient access to files within the system.

Uploaded by

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

Chapter 2 - File System Management

Chapter 8 discusses file systems, focusing on free space management, file attributes, and file operations. It covers various allocation methods such as contiguous, linked, and indexed allocation, detailing their advantages and disadvantages. Additionally, it explains directory structures and the importance of maintaining efficient access to files within the system.

Uploaded by

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

Chapter 8

File System
A Answer the following (1 Mark Questions) :
Marks for these Questions may vary from 1 to 2.

30" Ikxg"hqwt"korngogpvcvkqpu"qh"htgg"urceg"nkuv0" (October 2014)


Uqnwvkqp"
Free space list is implemented as:
i. Bit map / bit vector
ii. Linked list
iii. Counting
iv. Grouping

40" Ytkvg"ujqtv"pqvg"qp"eqr{"qp"ytkvg0"" (October 2013)"


Uqnwvkqp"
When fork() command is used, copy of parent space is male for child, duplicating the pages to the
parent.
Copy-on-write technique allows postponing of making copy of address space of parent by
allowing sharing of the same page by parent and child. This shared page is marked copy-on-write
and if either process writes to a shared page, a copy of the shared page is created.

50" Lwuvkh{<"›Pgyn{"etgcvgf"fktgevqt{"yknn"jcxg"vyq"gpvtkgu"cwvqocvkecnn{"kp"kvfiA"
" " "(April 2013)
Uqnwvkqp"
True, newly created directory will contain 2 entries as . and .. as parent and child directory entry.

60" Nkuv"fkhhgtgpv"yc{u"hqt"jcpfnkpi"htgg/urceg/nkuv"kp"hkng"u{uvgo0""(October 2012)


Uqnwvkqp"
Different ways to handle Free Space List in File System
i. Bit map / bit vector
ii. Linked list
iii. Counting
iv. Grouping

" V0[0""R0K/Qrgtcvkpi"U{uvgou""♦
♦ "0:/3"" ♦""Hkng"U{uvgo" "
" "V0[0""R0K/Qrgtcvkpi"U{uvgou"♦
♦ "0:/4"" ♦"Hkng"U{uvgo" "

70" Yjcv"ku"hkngA"Nkuv"cp{"vyq"cvvtkdwvgu"qh"hkng0"(April 2012)" "


Uqnwvkqp"
In the user’s view, a file is the smallest allotment of logical secondary storage. The data to be
written to secondary storage device should be in the file form. The collection of related information
can be named as a file.
File Attributes
i. Name: This is the only information kept in human readable form.
ii. Identifiers: It is a number (unique tag) which is use to identify the file in the file system.
iii. Type: It is used to support different types.
iv. Location: This is pointer to file location on device.
v. Size: It gives current size of the file. The maximum allowed size also included in this
attribute.
vi. Protection: Access controls, who can do reading, writing and execution.
vii. Time, date and user identification: This is the information kept for creation, last
modification, last use. It is kept for security, protection and monitor the usage of file.

B Answer the following (5 Marks Questions) :


Marks for these Questions may vary from 4 or 5.

30" Gzrnckp"vjg"eqpvkiwqwu"cnnqecvkqp"ogvjqf"ykvj"fkcitco0" (October 2014)"


Uqnwvkqp"

Each file occupy a set of contiguous blocks on the disk. Disk addresses are defined linearly. Here
assumption made is, only one job is accessing the disk. When job wants to access data, it access disk
contiguously, i.e., after reading block n, block n + 1 is accessed, so no head movement is required.
Whenever head movement from last sector of one cylinder to the first sector of the next cylinder, the
head need only move from one track to the next. In this approach of file allocation the number of
disk seeks required is minimal.
Contiguous allocation of a file is defined by the disk address and length of the first block. The
directory entry for each file indicates the address of starting block and the length of the blocks
allocated for this file. For example, if the file is n blocks long and starts at location b, then it
occupies blocks b, b + 1, b + 2… b + n – 1.
" "V0[0""R0K/Qrgtcvkpi"U{uvgou"♦
♦ "0:/5"" ♦"Hkng"U{uvgo" "

Following figure shows contiguous allocation of disk space.


fktgevqt{

file start length


count 0 2
count
0 2 3 tr 14 3
mail 19 6
f
list 28 4
4 5 6 7
f 6 2

8 9 10 11
tr
12 13 14 15

16 17 18 19
mail
20 21 22 23

24 25 26 27
list
28 29 30 31

"

Contiguous allocation of disk space


Files which are allocated in a contiguous fashions are easy to access.
i. For sequential access, it just remembers the disk address of last block referenced.
ii. For direct access to say block i of the file that starts at block b, we can access block b + i
directly.
iii. Thus both sequential and direct access can be supported by contiguous allocation.
iv. But contiguous allocation has numerous disadvantages.
Major difficulty with this approach is finding space for a new file.
To satisfy a request of size n from a list of free holes, different strategies are used. For
example, Best fit, first fit and worst fit. But all these strategies suffer from external
fragmentation.
40" Gzrnckp"vjg"dcuke"hkng"qrgtcvkqp0 (April 2014)"
Uqnwvkqp"
Basic File Operations
i. Creating a file: To create a file, first we need to find space in the file system for the file and
secondly, an entry for the new file must be made in the directory.
ii. Writing a file: To write a file, we need to pass file name and the information to be written to
the file. By using file name, the system searches the directory to find the file’s location. The
system maintains a write pointer to the location in the file where next write is to take place.
" "V0[0""R0K/Qrgtcvkpi"U{uvgou"♦
♦ "0:/6"" ♦"Hkng"U{uvgo" "

iii. Reading a file: To read from file, both the name of the file and buffer location (where the
block of file should be store). By using name, the directory is searched for associated entry.
System maintain read pointer to the location in the file where the next read is to for reading
and writing to file, each process maintain current file position pointer.
iv. Repositioning within file: The directory is searched for the appropriate entry and the current–
file position pointer is repositioned to a given value. This file operation is known as file seek.
v. Deleting a file: By using specified name, the directory is searched, if found system releases all
file space and erases the directory entry.
vi. Truncating a file: Keeping all attributes of the file, we can erase the content of the file. But if
the file length reset to zero then file space get released.

50" Ytkvg"c"pqvg"qp"ugswgpvkcn"ceeguu0""""""""""""""""""""""""""""""""""""""""""""""""""""""(April 2014) "


Uqnwvkqp"
Under this access method, the entire file is read or written from the beginning to the end
sequentially. This is the simplest access method.
Beginning Current position End

Rewind
Read or
write "

Sequential access file

Above figure shows sequential access file. The file is associated with a read/write pointer. A read
operation (read next) reads the next block of the file and automatically advances a file pointer. A
write operation (write next) appends to the end of the file and pointer points to the new end of file.
Files can be reset to the beginning. Also pointer can be skipped ‘n’ records forward or backward.

60" Fguetkdg"vtgg"uvtwevwtg"fktgevqtkgu"kp"fgvckn0"""""""" " " " " "(October 2013)"


Uqnwvkqp"
Tree is the most common directory structure.
For example
root spell bin programs

stat mail dist find count p e mail

prog copy prt exp

find list
hex count

Where represent file


"
"
" "V0[0""R0K/Qrgtcvkpi"U{uvgou"♦
♦ "0:/7"" ♦"Hkng"U{uvgo" "

Tree has a root directory-Every file in the system has a unique path name. The path name is the
path from the root, through all the subdirectories to a specified file.
In normal use, each user has current directory with specified system call, one can change
directory by giving path to be directory path name can be absolute or relative.
70" Gzrnckp" Nkpmgf" cpf" Kpfgzgf" hkng" cnnqecvkqp" ogvjqfu" cnqpi" ykvj" ogtkvu" cpf""
fgogtkvu0""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""(April 2013) "
Uqnwvkqp" "
Linked file allocation: In linked allocation approach, each file is a linked list of disk blocks,
which may be scattered anywhere on the disk. The direction entry for the file contains a pointer to
the first and last block of the file. Each block contains a pointer to the next block. These pointer are
hidden from the user.
Figure shows linked allocation of disk space.

fktgevqt{

file start end


jeep 9 25
0 2 3

4 5 6 7

8 9 10 2 11

12 13 14 15

16 17 18 19

20 21 22 23

24 25 -1 26 27

28 29 30 31

"

In above figure, a file of five blocks might starts at block 9 and continue at block 16, then block
1, then block 10 and finally block 25.
If each block is 512 in size, and a disk address requires 4 bytes, then user sees block of 508 bytes
and 4 bytes are kept reserved for pointer.
Whenever new file is created, a new entry in directory is made. Each directory entry has a pointer
to the first block of file (initially it is nil as file size is set to 0). When information is written to file,
free block is allocated to file and this new block is linked to the end of the file.
Whenever a file is read, we simply read blocks by following the pointer from block to block
" "V0[0""R0K/Qrgtcvkpi"U{uvgou"♦
♦ "0:/8"" ♦"Hkng"U{uvgo" "

Merits
i. There is no external fragmentation with linked allocation.
ii. File can be grown as much as user desire in this approach.
iii. No size of a file is known in advanced to the creator of the file.
Demerits
i. Linked allocation can be used effectively only for sequential access files. It is inefficient to
support a direct access of files.
Consider that we want to access ith block of file. We must start at the beginning of that file and
follow the pointers until we get to the ith block. Thus we have to access file sequentially.
ii. Another disadvantage of this approach is the space required for the pointers.
If we consider that 4 bytes are required to store pointer, 0.78 percent of disk is utilised for
pointers. One solution to this is, instead of blocks, clusters are used.
iii. Reliability is another issue in linked allocation. File is stored in scattered blocks linked by
pointers. But if a pointer is lost or damaged, we may pick up a wrong pointer or no pointer is
available while accessing the file.
Indexed file allocation: In indexed allocation, all pointers are kept together into the index table
following is the logical view of index table.
Each file has its own index block. An index block is an array of disk block addresses. The 1st
entry in the index block points to the 1st block of the file, 2nd entry points to the 2nd block and so on
the ith entry in the index block points to the ith block of the file. The directory entry contains the address of
the index block.
Figure shows index allocation of file.

fktgevqt{

file index block


jeep 19
0 2 3

4 5 6 7

8 9 10 11

9
12 13 14 15 16
1
10
16 17 18 19 19
25
1
20 21 22 23 1
1

24 25 26 27

28 29 30 31

"
" "V0[0""R0K/Qrgtcvkpi"U{uvgou"♦
♦ "0:/9"" ♦"Hkng"U{uvgo" "
th th
To access i block of the file, we use the pointer in the i index block entry.
Whenever file is created, all pointers in the index block are initialized to nil. Whenever data is
written to the block, a free block is obtained and its address is put in the appropriate index block
entry.
Merits
i. Index allocation do not suffer from external fragmentation.
ii. It supports direct access.
iii. Memory required to store index block is more than that of in linked allocation. No matter how
many pointers are there with non-nil value, we have to allocate memory to index block.

80" Gzrnckp"Vtgg/uvtwevwtgf"fktgevqtkgu"cnqpi"ykvj"cfxcpvcigu"cpf"fkucfxcpvcigu0"
(October 2012)
Uqnwvkqp"
In this structure, each user has separate directory.
Two levels of directories are used system’s Master File Directory (MFD) and User File Directory
(UFD).
Each user has his own UFD. Each UFD lists only the files of a single user. When a user process
starts, the MFD is searched. The MFD has indexes to point each entry point to the UFD for that user.
Two level directory can be thought of tree with height 2. The root is MFD and its children are UFDs.

Ocuvgt"hkng
fktgevqt{ User 1 User 2 User 3 User 4

Wugt"hkng a a x
Text B Max Min Test B Data b
fktgevqtkgu

Hkngu "

Advantages
i. Particular file is searched in specific user’s UFD, who is referring it. Hence same file name
can be used by different users.
ii. To create and delete file, the operating system searches only that user’s UFD.
iii. This structure isolates one user from another.
Disadvantages
i. If user wants to share their file’s data to perform some task, system does not allow local user
file to be accessed by other user.
" "V0[0""R0K/Qrgtcvkpi"U{uvgou"♦
♦ "0:/:"" ♦"Hkng"U{uvgo" "

ii. If any user wants to execute these system files, he gives command and command interpreter
treat such a command as the name of a file to load and execute. This file name would be
searched for in the current UFD we may then need to copy the system files into each UFD.
But this would be waste an large amount of space.

90" Gzrnckp"fkhhgtgpv"ogvjqfu"hqt"jcpfnkpi"htgg/urceg"nkuv"kp"hkng"u{uvgo0""""""
" " "(April 2012)""""
Uqnwvkqp"
The system maintains a free-space list to keep track of free disk space.
The free-space list contains all free disk blocks, i.e., the blocks which are not allocated to some
file or directory.
Whenever a new file is created, first the free-space list is searched for required amount of space
and allocates that space to the new file. This space is then removed from the free-space list.
When a file is deleted, its disk space is added to the free-space list.
Implementation of free space list is done by
i. Bit vector: The free-space list is implemented as a bit map or bit vector. Each block is
represented by 1 bit. If block is free, the bit is 1. If block is allocated to any file or directory,
the bit is 0.
ii. Linked list: In this approach, all the free blocks are linked together. Pointer to the first free
block is kept in a special location on the disk and cached in memory. First block contains a
pointer to the 2nd free block; second free block contains a pointer to third and so on.
iii. Grouping: In this approach, the address of n free blocks are stored in the first free block. The
first n–1 of these blocks are free blocks. The last (nth) block contains the addresses of another
n free blocks and so on. In this approach, traversing a list is avoided. Large number of free
blocks can be found quickly.
iv. Counting: In this approach, the address of the first free block and the number n(count) of free
contiguous blocks that follow the first block are stored. Each entry in the free-space list then
consists of a disk address and a count, it requires more space but the list is shorter.
v. Space maps: The space map is a log of all block activity (i.e., allocation and freeing of
blocks) in time order, in counting format. When ZFS has to allocate or free space from a
metaslab, it loads the associated space map into memory.
To make this operation efficient, it uses balanced-tree structure, indexed by offset. It replays
the log into that structure. The in-memory space map becomes accurate representation of the
allocated and free space in the metaslabs. ZFS combine contiguous free block as much as
possible in single entry. The free-space list is updated on disk. If during the process of the
collection and sorting phase, block request occurs, then ZFS satisfies these requests from the
log. Thus, the log and the balanced tree is the free-list.

You might also like