0% found this document useful (0 votes)
40 views41 pages

9-Allocation Methods, Directory, Implementation-06!11!2024

The document discusses file systems, detailing the structure, attributes, operations, and types of files, as well as access methods and directory organization. It explains allocation methods including contiguous, linked, and indexed allocation, highlighting their advantages and disadvantages. Additionally, it provides examples of disk I/O operations required for various file manipulations in different allocation strategies.

Uploaded by

gkearth8
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)
40 views41 pages

9-Allocation Methods, Directory, Implementation-06!11!2024

The document discusses file systems, detailing the structure, attributes, operations, and types of files, as well as access methods and directory organization. It explains allocation methods including contiguous, linked, and indexed allocation, highlighting their advantages and disadvantages. Additionally, it provides examples of disk I/O operations required for various file manipulations in different allocation strategies.

Uploaded by

gkearth8
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/ 41

File Systems

Geraldine Bessie Amali. D


Associate Professor
SCOPE
File is a named collection of relevant
information that is recorded on a
secondary storage.
The OS abstracts the physical properties
of the storage devices to define a logical
storage unit, the file.
File system resides on secondary storage
(disks).
File Control Block – storage structure
consisting of information about a file.
File has certain defined structure ,according to
its type. (text file, exe file, source file etc)
Information about files are kept in the directory
structure, and maintained on disks.
File Attributes
• Name –– is the information kept in human--readable form.
• Identifier – Unique number used to identify the file in the
file system.
• Type –– is needed for systems that support different types
• Location is a pointer to the device and to the location of file.
• Size –– The current size of the file ( in bytes, words)
• Protection–– access control information about who can do
reading, writing, executing.
• Time , date and user identification –– data for protection,
security, and usage monitoring.
File Operations
Creating a file –– space in the file system ,entry for
new file should be checked in directory.
Writing a file –– make a system call for specifying both
name and the information to be written to the file.
Write pointer is used.
Reading a file –– system call is used to specify the
name of the file. Read pointer is used.
Repositioning within file –– the directory is searched
for entry and current file position is set . (file seek)
Deleting a file –– we release all file space, if it is found
in directory to used by others
Truncating a file –– erasing the contents of the file.
File Types
Open Files
File Structure
• Disk systems typically have a well-defined block size
determined by
the size of a sector.
• All disk I/O is performed in units of one block (physical
record), and all blocks are the same size.
• The logical record size, physical block size, and packing
technique determine how many logical records are in each
physical block.
• Because disk space is always allocated in blocks, some
portion of the last block of each file is generally wasted.
• If each block were 512 bytes, for example, then a file of
1,949 bytes would be allocated four blocks (2,048 bytes); the
last 99 bytes would be wasted.
• All file systems suffer from internal fragmentation.
Access Methods
Sequential Access:
Sequential Access
Information in the file is processed in order, one record
after another.
Based on the tape model of the file.
Time consuming.
Operations:
Read Next – Reads the next portion of the file and
automatically advances a file pointer.
Write Next – Appends to the end of the file and
advances to the end of the newly written material.
Reset – To the beginning.
Direct Access(Relative access)
A file is made up of fixed length logical records that allow
programs to read and write in any particular order.
 Based on the disk model of the file.
Allows random access to any file block. From 56 to 3 etc.
Relative block number is used as n. (an index relative to
the beginning of the file).

Operations:
Read n – n is the block number
Write n – n is the block number
Other Access Methods
Index Files
It is built on top of the direct access
An Index is constructed that contains pointers to the various
blocks
To find a record we search the index and then use the pointer
to access the file directly and to find the desired record.
File System Organization
Directory Structure
Directory structure organizes and provides
information about all files in the system.
 Organization includes partitions and device
directory.
 Organizing includes naming, efficiency,
grouping.
 Device directory – each partition contains
information about all files in the system (volume
table of contents).
Information in the directory
Name of the file.
 Type of the file.
 Address of the file.
 Size of the file.
 Last accessed date of the file.
 Last updated date of the file.
 Owner Identification.
 Protection information.
Operations performed on a
directory
Search for a file
 Create a file
 Delete a file
 List a directory
 Traverse the file system
Single Level Directory
A single directory for all users
Naming problem - All files in the directory must have unique
names.
Grouping problem – logical grouping of files is difficult.
The single user can’t keep track of all files (daunting task).
Two-Level Directory
• Separate directory for each user.
• User File Directory – list the files of a single user.
• Master File Directory – indexed by user name or account
number, each entry points to the UFD.
• Different user can have the same file name.
• Efficient searching, and
• No grouping capability.
Tree-Structured Directories
 This generalization allows users to create their own sub-
directories and to organize their files accordingly.
 An absolute path name begins at the root and follows a path
down to the specified file, giving the directory names on the
path.
 A relative path name defines a path from the current
directory.
 Efficient searching and Grouping Capability.
 IF , the Current directory is root/spell/mail then relative path
name is prt/first and absolute path name is
root/spell/mail/prt/first.ss
Graph Directories
Allocation Methods
• An allocation method refers to how disk blocks are allocated
for files:

• Contiguous allocation

Operating System Concepts


• Linked allocation

• Indexed allocation
Contiguous Allocation
• Each file occupies a set of contiguous blocks on the disk.

• Simple – only starting location (block #) and length (number of blocks)


are required.

• Random access.

Operating System Concepts


• Wasteful of space (dynamic storage-allocation problem).

• Files cannot grow.


Contiguous Allocation of Disk
Space

Operating System Concepts


Extent-Based Systems
• Many newer file systems (I.e. Veritas File System) use a
modified contiguous allocation scheme.

• Extent-based file systems allocate disk blocks in extents.

Operating System Concepts


• An extent is a contiguous block of disks. Extents are allocated
for file allocation. A file consists of one or more extents.
Linked Allocation
• Each file is a linked list of disk blocks: blocks may be scattered
anywhere on the disk.

block = pointer

Operating System Concepts


Linked Allocation (Cont.)
• Simple – need only starting address
• Free-space management system – no waste of space
• No random access
• Mapping

Operating System Concepts


Q
LA/511
R

Block to be accessed is the Qth block in the linked chain


of blocks representing the file.
Displacement into block = R + 1
File-allocation table (FAT) – disk-space allocation used by
MS-DOS and OS/2.
Linked Allocation

Operating System Concepts


File-Allocation Table

Operating System Concepts


Indexed Allocation
• Brings all pointers together into the index block.
• Logical view.

Operating System Concepts


index table
Example of Indexed Allocation

Operating System Concepts


Indexed Allocation (Cont.)
• Need index table
• Random access
• Dynamic access without external fragmentation, but have
overhead of index block.
• Mapping from logical to physical in a file of maximum size

Operating System Concepts


of 256K words and block size of 512 words. We need only
1 block for index table.
Q
LA/512
R
Q = displacement into index table
R = displacement into block
Indexed Allocation – Mapping
(Cont.)

Operating System Concepts


outer-index

index table file


Consider a file currently consisting of 100 blocks. Assume that the
file control block (and the index block, in the case of indexed
allocation) is already in memory. Calculate how many disk I/O
operations are required for contiguous, linked, and indexed (single-
level) allocation strategies, if, for one block, the following
conditions hold. In the contiguous allocation case, assume that
there is no room to grow in the beginning, but there is room to
grow in the end. Assume that the block information to be added is
stored in memory.
(a) The block is added at the beginning.
• For contiguous allocation strategies, we need 100 disk
I/Os for reading the entire file into memory, 1 disk I/O for writing
the new block to disk at the beginning of the file ( in the 1st
block), and 100 disk I/Os for writing the remaining 100 blocks of
the file to disk starting from the 2nd block. In total, we need 201
disk I/Os.
• For linked allocation strategies, we need to change the
pointer in the file control block to point to the new block in disk.
In total, we need 1 disk I/Os.
• For indexed allocation strategies, we write the new block
to disk, and update indexed in memory.
(b) The block is added in the middle.
• For contiguous allocation strategies, we need 50 disk
I/Os for reading the last half of the file into memory, 1 disk
I/O for writing the new block to disk in the middle of the file
(in the 51st block), and 50 disk I/Os for writing the remaining
50 blocks of the file to disk starting from the 52nd block, and
1 disk I/O for writing the file control block to change the file
length to 100. In total, we need 101 disk I/Os.
• For linked allocation strategies, we read first 50
blocks, modify the point of 50th block, write new block to
first block. In total, we need 52 disk I/Os.
• For indexed allocation strategies, we write the new
block to disk, and update indexed in memory.
(c) The block is added at the end.
• For contiguous allocation strategies, we write block in
to the end of file. Hence, we need 1 disk I/Os.
• For linked allocation strategies, we read the last
block(using the point of end block), and then modify it, write
new block to first block. In total, we need 3 disk I/Os.
• For indexed allocation strategies, we write the new
block to disk, and update indexed in memory.
The block is removed from the beginning.

• For contiguous allocation strategies, we need 99 disk I/Os for


reading the last 99 blocks into memory, and 99 disk I/Os for
writing the 99 blocks back to disk at the beginning of the file.
In total, we need 198 disk I/Os.
• For linked allocation strategies, we read the first
block and copy it's point to the point of beginning(copying is
in the memory). In total, we need 1 disk I/Os.
• For indexed allocation strategies, we update indexed
in memory.
(e) The block is removed from the middle.
• For contiguous allocation strategies, we need 49 disk
I/Os for reading the last 49 blocks into memory, and 49 disk
I/Os for writing the 49 blocks back to disk starting from the
51th block. In total, we need 98 disk I/Os.
• For linked allocation strategies, we read the first 51
block and copy the point of 51th to the point of 50th. In total,
we need 52 disk I/Os.
• For indexed allocation strategies, we update indexed
in memory.
f. What if the block is removed from the end?
• For contiguous allocation strategies, we only need to
update size in memory. In total, we need 0 disk I/Os.
• For linked allocation strategies, we read the first 99 block
and copy the point of end to the point of 99th (if no end
pointer). In total, we need 100 disk I/Os.
• For indexed allocation strategies, we also update indexed
in memory. Also 0 I/Os.

You might also like