Download as pdf or txt
Download as pdf or txt
You are on page 1of 28

Section-V

1. Discover the importance of disk scheduling algorithms in optimizing I/O operations. Provide examples of disk
scheduling algorithms and their impact on system performance.

Disk scheduling algorithms play a crucial role in optimizing input/output (I/O) operations in computer systems. These
algorithms determine the order in which pending I/O requests are serviced by the disk. Since disk operations are inherently
slower compared to other components of a computer system, efficient disk scheduling can significantly impact overall
system performance by reducing the latency and maximizing throughput. Some key reasons of disk scheduling algorithms
are important:

Minimization of seek time: Seek time is the time taken by the disk arm to position itself over the desired track. Disk
scheduling algorithms aim to minimize seek time by organizing the sequence of I/O requests in a manner that reduces the
amount of movement required by the disk arm. This leads to faster access to data and improved system responsiveness.

Reduction of rotational latency: Rotational latency refers to the time it takes for the desired sector to rotate under the
disk head once the arm is positioned over the correct track. Disk scheduling algorithms can reduce rotational latency by
optimizing the order of I/O requests to minimize the distance the disk head needs to travel between adjacent sectors.

Fairness and throughput optimization: In multi-user or multi-process environments, disk scheduling algorithms need to
ensure fairness in servicing I/O requests from different processes or users while maximizing overall disk throughput. By
intelligently prioritizing and scheduling I/O requests, these algorithms can achieve a balance between fairness and
throughput, ensuring efficient utilization of disk resources.

Some examples of disk scheduling algorithms and their impact on system performance:

First-Come, First-Served (FCFS):

FCFS is the simplest disk scheduling algorithm where I/O requests are serviced in the order they arrive.
Impact: While FCFS is easy to implement, it doesn't consider seek time or rotational latency, leading to potentially high
response times and poor disk utilization, especially in scenarios with mixed workloads.

Shortest Seek Time First (SSTF):

SSTF selects the I/O request that requires the shortest seek time from the current head position.
Impact: SSTF can significantly reduce average seek time compared to FCFS, resulting in improved system responsiveness
and reduced disk latency. However, it may lead to starvation of requests located farther from the current head position.

SCAN (Elevator):

SCAN moves the disk arm in one direction (e.g., towards the outer tracks) while servicing requests in that direction. When
it reaches the end, it reverses direction.
Impact: SCAN provides fairness by servicing both inner and outer tracks, reducing the likelihood of starvation. It also
reduces average seek time compared to FCFS by minimizing back-and-forth movement of the disk arm.

C-SCAN:
C-SCAN is similar to SCAN but instead of reversing direction at the end, it jumps to the other end of the disk.
Impact: C-SCAN reduces variance in response times compared to SCAN by ensuring that all requests are serviced within a
bounded time interval. However, it may increase average seek time for requests located near the boundaries.

These examples illustrate how different disk scheduling algorithms can have a significant impact on system performance
by optimizing seek time, rotational latency, fairness, and throughput. The choice of algorithm depends on factors such as
workload characteristics, system requirements, and implementation considerations.

2. Consider a disk queue with requests for I/O to blocks on cylinders 98, 183, 41, 122, 14, 124, 65, 67. The FCFS scheduling
algorithm is used. The head is initially at cylinder number 53. The cylinders are numbered from 0 to 199. The total head
movement (in number of cylinders) incurred while servicing these requests is ?

Initial head position: 53


Requests for I/O to blocks on cylinders: 98, 183, 41, 122, 14, 124, 65, 67

We'll calculate the absolute differences between consecutive cylinder numbers and then sum them up.

From 53 to 98: ∣98−53∣=45∣98−53∣=45


From 98 to 183: ∣183−98∣=85∣183−98∣=85
From 183 to 41: ∣183−41∣=142∣183−41∣=142
From 41 to 122: ∣122−41∣=81∣122−41∣=81
From 122 to 14: ∣122−14∣=108∣122−14∣=108
From 14 to 124: ∣124−14∣=110∣124−14∣=110
From 124 to 65: ∣124−65∣=59∣124−65∣=59
From 65 to 67: ∣67−65∣=2∣67−65∣=2

Now, summing up these absolute differences:

45+85+142+81+108+110+59+2=63245+85+142+81+108+110+59+2=632

So, the total head movement incurred while servicing these requests using the FCFS scheduling algorithm is 632 cylinders.

3.Interpret different file allocation methods such as contiguous, linked, and indexed allocation. What are the advantages
and disadvantages of each method?

ALLOCATION METHODS

 There are three major methods of storing files on disks: contiguous, linked, and indexed.

Contiguous Allocation

 Contiguous Allocation requires that all blocks of a file be kept together contiguously.
 Performance is very fast, because reading successive blocks of the same file generally requires no
movement of the disk heads, or at most one small step to the next adjacent cylinder.
 Storage allocation involves the same issues discussed earlier for the allocation of contiguous blocks
of memory ( first fit, best fit, fragmentation problems, etc. ) The distinction is that the high time penalty
required for moving the disk heads from spot to spot may now justify the benefits of keeping files
contiguously when possible.
 ( Even file systems that do not by default store files contiguously can benefit from certain utilities
thatcompact the disk and make all files contiguous in the process. )
 Problems can arise when files grow, or if the exact size of a file is unknown at creation time:
o Over-estimation of the file's final size increases external fragmentation and wastes disk space.
o Under-estimation may require that a file be moved or a process aborted if the file grows beyond its
originally allocated space.
o If a file grows slowly over a long time period and the total final space must be allocated initially,
thena lot of space becomes unusable before the file fills the space.
 A variation is to allocate file space in large contiguous chunks, called extents. When a file outgrows
its original extent, then an additional one is allocated. ( For example an extent may be the size of a
complete track or even cylinder, aligned on an appropriate track or cylinder boundary. ) The high-
performance files system Veritas uses extents to optimize performance.

Contiguous allocation of disk space.

Linked Allocation

 Disk files can be stored as linked lists, with the expense of the storage space consumed by each link. (
E.g. a block may be 508 bytes instead of 512. )
 Linked allocation involves no external fragmentation, does not require pre-known file sizes, and
allows files to grow dynamically at any time.
 Unfortunately linked allocation is only efficient for sequential access files, as random access
requiresstarting at the beginning of the list for each new location access.
 Allocating clusters of blocks reduces the space wasted by pointers, at the cost of
internalfragmentation.
 Another big problem with linked allocation is reliability if a pointer is lost or damaged. Doubly linked
lists provide some protection, at the cost of additional overhead and wasted space.
Linked allocation of disk space.

The File Allocation Table, FAT, used by DOS is a variation of linked allocation, where all the links are
stored in a separate table at the beginning of the disk. The benefit of this approach is that the FAT table
can be cached in memory, greatly improving random access speeds.

File-allocation table.

Indexed Allocation

 Indexed Allocation combines all of the indexes for accessing each file into a common block ( for that
file ), as opposed to spreading them all over the disk or storing them in a FAT table.
Indexed allocation of disk space.

 Some disk space is wasted ( relative to linked lists or FAT tables ) because an entire index block must
be allocated for each file, regardless of how many data blocks the file contains. This leads to questions
of how big the index block should be, and how it should be implemented. There are several approaches:
o Linked Scheme - An index block is one disk block, which can be read and written in a single disk
operation. The first index block contains some header information, the first N block addresses, and if
necessary a pointer to additional linked index blocks.
o Multi-Level Index - The first index block contains a set of pointers to secondary index blocks, which
in turn contain pointers to the actual data blocks.
o Combined Scheme - This is the scheme used in UNIX inodes, in which the first 12 or so data block
pointers are stored directly in the inode, and then singly, doubly, and triply indirect pointers provide
access to more data blocks as needed. ( See below. ) The advantage of this scheme is that for small files (
which many are ), the data blocks are readily accessible ( up to 48K with 4K block sizes ); files up to about
4144K ( using 4K blocks ) are accessible with only a single indirect block ( which can be cached ),and huge
files are still accessible using a relatively small number of disk accesses ( larger in theory thancan be addressed by
a 32-bit address, which is why some systems have moved to 64-bit file pointers. )

The UNIX inode.

Performance

 The optimal allocation method is different for sequential access files than for random access files,
andis also different for small files than for large files.
 Some systems support more than one allocation method, which may require specifying how the file
is to be used ( sequential or random access ) at the time it is allocated. Such systems also provide
conversion utilities.
 Some systems have been known to use contiguous access for small files, and automatically switch to
an indexed scheme when file sizes surpass a certain threshold.
 And of course some systems adjust their allocation schemes ( e.g. block sizes ) to best match the
characteristics of the hardware for optimum performance.
3. Identify the system calls for file I/O operations -

A) open(), create(), read(), write(), close() (4M)

B) lseek(), stat(), and ioctl() (4M)

A) The system calls for file I/O operations are:

open(): Opens a file and returns a file descriptor that can be used for subsequent I/O operations.
create(): Creates a new file with the specified name and permissions.
read(): Reads data from an open file descriptor into a buffer.
write(): Writes data from a buffer to an open file descriptor.
close(): Closes an open file descriptor, releasing associated resources.

These system calls are fundamental for performing basic file I/O operations in a Unix-like operating system.

B) The system calls mentioned are:

lseek(): Repositions the file offset of an open file descriptor.


stat(): Retrieves information about a file, such as its size, permissions, and timestamps.
ioctl(): Performs I/O control operations on devices or streams.

These system calls provide additional functionality related to file management and I/O control beyond the basic
read/write operations.
50 Construct the structure of a disk in a mass storage system. How is data organized on a disk, and examine the key
components of disk management?

In a mass storage system, a disk typically consists of several key components organized in a hierarchical
structure. Let's examine the structure of a disk and how data is organized on it, along with the key components
of disk management:

Platters:

A disk consists of one or more circular platters made of a magnetic material, such as metal or glass.
Data is stored on the surfaces of these platters in the form of magnetic patterns.

Tracks:

Each platter is divided into concentric circular tracks.


Tracks are the smallest unit of storage on a disk and represent a single circular path on the disk surface.

Sectors:
Each track is further divided into sectors.
A sector is the smallest addressable unit of data on a disk and typically stores a fixed amount of data, such as
512 bytes or 4 KB.
Sectors are accessed individually by the disk's read/write heads.

Cylinders:

A cylinder is formed by all the tracks with the same track number across all platters.
For example, track 0 on all platters forms cylinder 0, track 1 on all platters forms cylinder 1, and so on.
Cylinders represent the vertical alignment of tracks and are used for optimizing disk access.

Read/Write Heads:

Read/write heads are mechanisms mounted on an actuator arm that move across the disk surfaces to read or
write data.
Each platter has its own set of read/write heads.
The heads magnetically read data from or write data to the disk surface.

Disk Controller:

The disk controller is responsible for managing data transfer between the disk and the computer's memory.
It communicates with the CPU via the disk interface (e.g., SATA, SCSI, NVMe).
The controller interprets commands from the CPU, controls the movement of the read/write heads, and
manages data buffering and error correction.

File System:

The file system is a higher-level abstraction that organizes and manages data on the disk.
It provides a logical structure for storing and accessing files and directories.
The file system manages disk space allocation, file naming, directory organization, and access control.

Key components of disk management include:

Disk Partitioning: Dividing the physical disk into logical partitions, each with its own file system.
Disk Formatting: Preparing the disk for use by initializing its file system structures and data structures.
Disk I/O Management: Handling read and write requests from the operating system, including scheduling,
buffering, and error handling.
Disk Defragmentation: Reorganizing data on the disk to optimize performance by reducing fragmentation.
Disk Monitoring and Maintenance: Monitoring disk health, performance, and usage, and performing
maintenance tasks such as error checking and bad sector remapping.

A) Explain about single-level, two-level and tree level diSingle-Level Directory

 Simple to implement, but each file must have a unique name.

Single-level directory.

Two-Level Directory

 Each user gets their own directory space.


 File names only need to be unique within a given user's directory.
 A master file directory is used to keep track of each users directory, and must be maintained when users
areadded to or removed from the system.
 A separate directory is generally needed for system ( executable ) files.
 Systems may or may not allow users to access other directories besides their own
o If access to other directories is allowed, then provision must be made to specify the directory being
accessed.
o If access is denied, then special consideration must be made for users to run programs located in system
directories. A search path is the list of directories in which to search for executable programs, and can be
set uniquely for each user.

Two-level directory structure.

Tree-Structured Directories

An obvious extension to the two-tiered directory structure, and the one with which we are all most
familiar.
 Each user / process has the concept of a current directory from which all ( relative ) searches take place.
Filesmay be accessed using either absolute pathnames ( relative to the root of the tree ) or relative
pathnames ( relative to the current directory. )
Directories are stored the same as any other file in the system, except there is a bit that identifies them as
directories, and they have some special structure that the OS understands.
One question for consideration is whether or not to allow the removal of directories that are not empty -
Windows requires that directories be emptied first, and UNIX provides an option for deleting entire sub-
trees.

Tree-structured directory structure.

Acyclic-Graph Directories

 When the same files need to be accessed in more than one place in the directory structure ( e.g.
because they are being shared by more than one user / process ), it can be useful to provide an acyclic-
graph structure. ( Note the directed arcs from parent to child. )
 UNIX provides two types of links for implementing the acyclic-graph structure. ( See "man ln" for
more details. )
o A hard link ( usually just called a link ) involves multiple directory entries that both refer to the same
file. Hard links are only valid for ordinary files in the same file system.
o A symbolic link, that involves a special file, containing information about where to find the linked
file. Symbolic links may be used to link directories and/or files in other file systems, as well as
ordinaryfiles in the current file system.
 Windows only supports symbolic links, termed shortcuts.
 Hard links require a reference count, or link count for each file, keeping track of how many directory
entries are currently referring to this file. Whenever one of the references is removed the link count is
reduced, and when it reaches zero, the disk space can be reclaimed.
 For symbolic links there is some question as to what to do with the symbolic links when the original
file is moved or deleted:
o One option is to find all the symbolic links and adjust them also.
o Another is to leave the symbolic links dangling, and discover that they are no longer valid the next
time they are used.
o What if the original file is removed, and replaced with another file having the same name before the
symbolic link is next used?
B) Design the structure of File System.(4M

File Structure

 Some files contain an internal structure, which may or may not be known to the OS.
 For the OS to support particular file formats increases the size and complexity of the OS.
UNIX treats all files as sequences of bytes, with no further consideration of the internal structure.
( With
the exception of executable binary programs, which it must know how to load and find the first
executable statement, etc. )
Macintosh files have two forks - a resource fork, and a data fork. The resource fork contains information
relating to the UI, such as icons and button images, and can be modified independently of the data fork,
which contains the code or data as appropriate.

Internal File Structure

 Disk files are accessed in units of physical blocks, typically 512 bytes or some power-of-two multiple
thereof. ( Larger physical disks use larger block sizes, to keep the range of block numbers within the range
of a 32-bit integer. )
 Internally files are organized in units of logical units, which may be as small as a single byte, or may
be a larger size corresponding to some data record or structure size.
 The number of logical units which fit into one physical block determines its packing, and has an
impact on the amount of internal fragmentation ( wasted space ) that occurs.
 As a general rule, half a physical block is wasted for each file, and the larger the block sizes the
morespace is lost to internal fragmentation.

Access Methods

Sequential Access

 A sequential access file emulates magnetic tape operation, and generally supports a few operations:
o read next - read a record and advance the tape to the next position.
o write next - write a record and advance the tape to the next position.
o rewind
o skip n records - May or may not be supported. N may be limited to positive numbers, or may
belimited to +/- 1.

Sequential-access file.

Direct Access

 Jump to any record and read that record. Operations supported include:
oread n - read record number n. ( Note an argument is now required. )
owrite n - write record number n. ( Note an argument is now required. )
ojump to record n - could be 0 or the end of file.
o Query current record - used to return back to this record later.
o Sequential access can be easily emulated using direct access. The inverse is complicated and inefficient.

Simulation of sequential access on a direct-access file.

Other Access Methods

 An indexed access scheme can be easily built on top of a direct access system. Very large files may
requirea multi-tiered indexing scheme, i.e. indexes of indexes.
Example

of index and

relative

files.

Directory

Structure

Storage Structure

 A disk can be used in its entirety for a file system.


 Alternatively a physical disk can be broken up into multiple partitions, slices, or
mini-disks, each of whichbecomes a virtual disk and can have its own filesystem.
( or be used for raw storage, swap space, etc. )
 Or, multiple physical disks can be combined into one volume, i.e. a larger
virtual disk, with its ownfilesystem spanning the physical disks.
A typical file-system organization.Directory Overview
 Directory operations to be supported include:
o Search for a file
o Create a file - add to the directory
o Delete a file - erase from the directory
o List a directory - possibly ordered in different ways.
o Rename a file - may change sorting order
o Traverse the file system.

Q) Discuss in detail about various File Allocation Methods with neat diagrams.

ALLOCATION METHODS

 There are three major methods of storing files on disks: contiguous, linked, and
indexed.

Contiguous Allocation

 Contiguous Allocation requires that all blocks of a file be kept together


contiguously.
 Performance is very fast, because reading successive blocks of the same
file generally requires no movement of the disk heads, or at most one small
step to the next adjacent cylinder.
 Storage allocation involves the same issues discussed earlier for the
allocation of contiguous blocks of memory ( first fit, best fit, fragmentation
problems, etc. ) The distinction is that the high time penalty required for
moving the disk heads from spot to spot may now justify the benefits of
keeping files contiguously when possible.
 ( Even file systems that do not by default store files contiguously can
benefit from certain utilities that compact the disk and make all files
contiguous in the process. )
 Problems can arise when files grow, or if the exact size of a file is unknown at
creation time:
o Over-estimation of the file's final size increases external fragmentation and
wastes disk space.
o Under-estimation may require that a file be moved or a process aborted if
the file grows beyond its originally allocated space.
o If a file grows slowly over a long time period and the total final space must
be allocated initially, then a lot of space becomes unusable before the file fills
the space.
 A variation is to allocate file space in large contiguous chunks, called
extents. When a file outgrows its original extent, then an additional one is
allocated. ( For example an extent may be the size of a complete track or even
cylinder, aligned on an appropriate track or cylinder boundary. ) The high-
performance files system Veritas uses extents to optimize performance.
Contiguous

allocation

of disk

space.

Linked

Allocation

 Disk files can be stored as linked lists, with the expense of the storage space
consumed by each link. (
E.g. a block may be 508 bytes instead of 512. )
 Linked allocation involves no external fragmentation, does not require pre-
known file sizes, andallows files to grow dynamically at any time.
 Unfortunately linked allocation is only efficient for sequential access files,
as random access requiresstarting at the beginning of the list for each new
location access.
 Allocating clusters of blocks reduces the space wasted by
pointers, at the cost of internalfragmentation.
 Another big problem with linked allocation is reliability if a pointer is lost or
damaged. Doubly linkedlists provide some protection, at the cost of additional
overhead and wasted space.
Linked allocation of disk space.

The File Allocation Table, FAT, used by DOS is a variation of linked


allocation, where all the links are stored in a separate table at the beginning of
the disk. The benefit of this approach is that the FAT table can be cached in
memory, greatly improving random access speeds.

File-allocation table.Indexed Allocation

 Indexed Allocation combines all of the indexes for accessing each file into
a common block ( for thatfile ), as opposed to spreading them all over the disk
or storing them in a FAT table.

Indexed allocation of disk space.

 Some disk space is wasted ( relative to linked lists or FAT tables ) because
an entire index block must be allocated for each file, regardless of how many
data blocks the file contains. This leads to questions of how big the index block
should be, and how it should be implemented. There are several approaches:
o Linked Scheme - An index block is one disk block, which can be read and
written in a single disk operation. The first index block contains some header
information, the first N block addresses, and if necessary a pointer to
additional linked index blocks.
o Multi-Level Index - The first index block contains a set of pointers to
secondary index blocks, which in turn contain pointers to the actual data
blocks.
o Combined Scheme - This is the scheme used in UNIX inodes, in which the
first 12 or so data block pointers are stored directly in the inode, and then
singly, doubly, and triply indirect pointers provide access to more data blocks
as needed. ( See below. ) The advantage of this scheme is that for small files (
which many are ), the data blocks are readily accessible ( up to 48K with 4K
block sizes ); files up to about 4144K ( using 4K blocks ) are accessible with
only a single indirect block ( which can be cached ),
and huge files are still accessible using a relatively small number of disk
accesses ( larger in theory thancan be addressed by a 32-bit address, which is
why some systems have moved to 64-bit file pointers. )

Q) What is Disk scheduling ? Explain different Disk scheduling algorithms:


FCFS,SCAN,CSCAN,CLOOK.

DISK

SCHE

DULI

NG

 As mentioned earlier, disk transfer speeds are limited primarily by seek times
and rotational latency.
When multiple requests are to be processed there is also some inherent delay in
waiting for other requests tobe processed.
 Bandwidth is measured by the amount of data transferred divided by
the total amount of time fromthe first request being made to the last transfer
being completed, ( for a series of disk requests. )
 Both bandwidth and access time can be improved by processing requests in a
good order.
 Disk requests include the disk address, memory address, number of
sectors to transfer, and whetherthe request is for reading or writing.

FCFS Scheduling

 First-Come First-Serve is simple and intrinsically fair, but not very efficient.
Consider in the following sequence the wild swing from cylinder 122 to 14
and then back to 124:

Figure -FCFS disk scheduling.

SSTF Scheduling

 Shortest Seek Time First scheduling is more efficient, but may lead to
starvation if a constant stream of requests arrives for the same general
area of the disk.
 SSTF reduces the total head movement to 236 cylinders, down from 640
required for the same set of requests under FCFS. Note, however that the
distance could be reduced still further to 208 by starting with 37 and then
14 first before processing the rest of the requests.
Figure - SSTF disk scheduling.

SCAN Scheduling

 The SCAN algorithm, a.k.a. the elevator algorithm moves back and forth
from one end of the disk to the other, similarly to an elevator processing
requests in a tall building.

Figure - SCAN disk scheduling.

 Under the SCAN algorithm, If a request arrives just ahead of the moving
head then it will be processed right away, but if it arrives just after the
head has passed, then it will have to wait for the head to pass going the
other way on the return trip. This leads to a fairly wide variation in access
times which can be improved upon.
 Consider, for example, when the head reaches the high end of the disk:
Requests with high cylinder numbers just missed the passing head, which
means they are all fairly recent requests, whereas requests with low
numbers may have been waiting for a much longer time. Making the
return scan from high to low then ends up accessing recent requests first
and making older requests wait that much longer.

C-SCAN Scheduling

 The Circular-SCAN algorithm improves upon SCAN by treating all requests


in a circular queue fashion - Once the head reaches the end of the disk, it
returns to the other end without processing any requests, and then starts
again from the beginning of the disk:
Figure - C-SCAN disk scheduling.
LOOK Scheduling

 LOOK scheduling improves upon SCAN by looking ahead at the queue of


pending requests, and not moving the heads any farther towards the end
of the disk than is necessary. The following diagram illustrates the circular
form of LOOK:

Figure 4.32- C-

LOOK disk

scheduling.

Selection of a

Disk-Scheduling

Algorithm

 With very low loads all algorithms are equal, since there will normally only
be one request to processat a time.
 For slightly larger loads, SSTF offers better performance than FCFS, but
may lead to starvation whenloads become heavy enough.
 For busier systems, SCAN and LOOK algorithms eliminate starvation problems.
 The actual optimal algorithm may be something even more complex than
those discussed here, but the incremental improvements are generally not
worth the additional overhead.
 Some improvement to overall filesystem access times can be made by
intelligent placement of directory and/or inode information. If those
structures are placed in the middle of the disk instead of at the beginning
of the disk, then the maximum distance from those structures to data
blocks is reduced to only one-half of the disk size. If those structures can
be further distributed and furthermore have their data blocks stored as
close as possible to the corresponding directory structures, then that
reduces still further the overall time to find the disk block numbers and
then access the corresponding data blocks.
 On modern disks the rotational latency can be almost as significant as the
seek time, however it is not within the OSes control to account for that,
because modern disks do not reveal their internal sector mapping
schemes, ( particularly when bad blocks have been remapped to spare
sectors. )
o Some disk manufacturers provide for disk scheduling algorithms
directly on their disk controllers, ( which do know the actual
geometry of the disk as well as any remapping ), so that if a series
of requests are sent from the computer to the controller then
those requests can be processed in an optimal order.
o Unfortunately there are some considerations that the OS must take
into account that are beyond the abilities of the on-board disk-
scheduling algorithms, such as priorities of some requests over
others, or the need to process certain requests in a particular
order. For this reason OSes may elect to spoon-feed requests to the
disk controller one at a time in certain situationQ) Write a detailed
notes on the File Access Methods .
Access Methods Sequential Access

 A sequential access file emulates magnetic tape operation, and generally


supports a few operations:
o read next - read a record and advance the tape to the next position.
o write next - write a record and advance the tape to the next position.
o rewind
o skip n records - May or may not be supported. N may be limited to
positive numbers, or may belimited to +/- 1.
Sequential-access file.Direct Access

 Jump to any record and read that record. Operations supported include:
oread n - read record number n. ( Note an
argument is now required. ) owrite n - write
record number n. ( Note an argument is now
required. )ojump to record n - could be 0 or the
end of file.
o Query current record - used to return back to this record later.
o Sequential access can be easily emulated using direct access. The inverse is
complicated and inefficient.

Simulation of sequential

access on a direct-access file.

Other Access Methods

 An indexed access scheme can be easily built on top of a direct access system.
Very large files may requirea multi-tiered indexing scheme, i.e. indexes of
indexes.

Example of index and relative files.

Directory Structure

Storage Structure
A disk can be used in its entirety for a file system.
Alternatively a physical disk can be broken up into multiple partitions, slices, or
mini-disks, each of whichbecomes a virtual disk and can have its own filesystem.
( or be used for raw storage, swap space, etc. )
 Or, multiple physical disks can be combined into one volume, i.e. a larger
virtual disk, with its ownfilesystem spanning the physical disks.
A typical file-system organization.Directory Overview

 Directory operations to be supported include:


o Search for a file
o Create a file - add to the directory
o Delete a file - erase from the directory
o List a directory - possibly ordered in different ways.
o Rename a file - may change sorting order
o Traverse the file system.

Q) Discuss in detail about various File Allocation Methods with neat diagrams.

ALLOCATION METHODS

 There are three major methods of storing files on disks: contiguous, linked, and
indexed.

Contiguous Allocation

 Contiguous Allocation requires that all blocks of a file be kept together


contiguously.
 Performance is very fast, because reading successive blocks of the same
file generally requires no movement of the disk heads, or at most one small
step to the next adjacent cylinder.
 Storage allocation involves the same issues discussed earlier for the
allocation of contiguous blocks of memory ( first fit, best fit, fragmentation
problems, etc. ) The distinction is that the high time penalty required for
moving the disk heads from spot to spot may now justify the benefits of
keeping files contiguously when possible.
 ( Even file systems that do not by default store files contiguously can
benefit from certain utilities that compact the disk and make all files
contiguous in the process. )
 Problems can arise when files grow, or if the exact size of a file is unknown at
creation time:
o Over-estimation of the file's final size increases external fragmentation and
wastes disk space.
o Under-estimation may require that a file be moved or a process aborted if
the file grows beyond its originally allocated space.
o If a file grows slowly over a long time period and the total final space must
be allocated initially, then a lot of space becomes unusable before the file fills
the space.
A variation is to allocate file space in large contiguous chunks, called extents. When a file
outgrows its original extent, then an additional one is allocated. ( For example an extent may be
the size of a complete track or even cylinder, aligned on an appropriate track or cylinder
boundary. ) The high- performance files system Veritas uses extents to optimize perfor

 A sequential access file emulates magnetic tape operation, and generally


supports a few operations:
o read next - read a record and advance the tape to the next position.
o write next - write a record and advance the tape to the next position.
o rewind
o skip n records - May or may not be supported. N may be limited to
positive numbers, or may belimited to +/- 1.

 Jump to any record and read that record. Operations supported include:
oread n - read record number n. ( Note an
argument is now required. ) owrite n - write
record number n. ( Note an argument is now
required. )ojump to record n - could be 0 or the
end of file.
o Query current record - used to return back to this record later.
o Sequential access can be easily emulated using direct access. The inverse is
complicated and inefficient.
Simulation of sequential

access on a direct-access file.

Other Access Methods

 An indexed access scheme can be easily built on top of a direct access system.
Very large files may requirea multi-tiered indexing scheme, i.e. indexes of
indexes.

Directory

Structure

Storage Structure

 A disk can be used in its entirety for a file system.


 Alternatively a physical disk can be broken up into multiple partitions, slices, or
mini-disks, each of whichbecomes a virtual disk and can have its own filesystem.
( or be used for raw storage, swap space, etc. )
 Or, multiple physical disks can be combined into one volume, i.e. a larger
virtual disk, with its ownfilesystem spanning the physical disks.
A typical file-system organization.Directory Overview

 Directory operations to be supported include:


o Search for a file
o Create a file - add to the directory
o Delete a file - erase from the directory
o List a directory - possibly ordered in different ways.
o Rename a file - may change sorting order
o Traverse the file system.

Q)Summarize the operations performed on a File?

Operations Performed on a File

Files are fundamental elements in an operating system, facilitating data storage and management.
The primary operations performed on files include:

1. Creating a File:
o Allocates space on the storage medium.
o Initializes necessary control structures and metadata.
o Typically involves assigning a file name and setting initial attributes like permissions.
2. Opening a File:
o Establishes a link between the file and a process, making the file accessible.
o Specifies the mode of access (e.g., read, write, append).
3. Reading from a File:
o Transfers data from the file into a buffer in memory.
o Can be done sequentially (one record after another) or randomly (specific records).
4. Writing to a File:
o Moves data from a buffer in memory to the file.
o Can append data to the end or overwrite existing data.
5. Closing a File:
o Ends the link between the file and the process.
o Ensures any remaining buffered data is written to the storage device and updates
metadata.
6. Deleting a File:
o Removes the file from the file system.
o Frees up the allocated space and updates the directory structure.
7. Repositioning within a File (Seek):
o Adjusts the file’s read/write pointer to a specified location.
o Facilitates random access by allowing jumps to different parts of the file.
8. Appending to a File:
o Adds data to the end of the file without altering existing content.
o Commonly used for log files and continuous data addition.

These operations ensure that files are effectively managed, accessed, and maintained within the
operating system, supporting a wide range of applications and user needs.

Q) Evaluate File System protection with its goals

Evaluation of File System Protection and Its Goals

File system protection is critical for ensuring the security, integrity, and availability of data
stored within a file system. This involves implementing mechanisms to prevent unauthorized
access, detect and respond to security breaches, and ensure that data is not lost or corrupted.
Here’s an evaluation of file system protection with its primary goals:

Goals of File System Protection

1. Data Confidentiality:
o Objective: Ensure that sensitive information is accessible only to authorized users.
o Mechanisms: Encryption, access control lists (ACLs), user authentication.
o Evaluation: Effective confidentiality measures prevent unauthorized data access,
protecting sensitive information from being exposed. Encryption is particularly effective,
but it needs proper key management to be secure.
2. Data Integrity:
o Objective: Maintain the accuracy and consistency of data throughout its lifecycle.
o Mechanisms: Checksums, hash functions, version control, access controls.
o Evaluation: Integrity mechanisms ensure that data is not altered or tampered with,
either accidentally or maliciously. Implementing strong integrity checks can prevent
data corruption and unauthorized modifications.
3. Data Availability:
o Objective: Ensure that data is available to authorized users when needed.
o Mechanisms: Redundant storage, regular backups, disaster recovery plans, RAID
systems.
o Evaluation: High availability is critical for maintaining business continuity. Redundancy
and regular backups ensure that data can be recovered in the event of hardware failure
or other disasters, minimizing downtime.
4. Authentication and Authorization:
o Objective: Verify the identity of users (authentication) and ensure they have
appropriate permissions (authorization).
o Mechanisms: User login credentials, multi-factor authentication (MFA), role-based
access control (RBAC).
o Evaluation: Robust authentication and authorization mechanisms are fundamental for
securing access to the file system. MFA enhances security by requiring additional
verification steps, reducing the risk of unauthorized access.

Methods to Achieve File System Protection

1. Access Control Lists (ACLs):


o Description: Specify which users or groups can access specific files and the type of
access they are allowed (read, write, execute).
o Evaluation: ACLs provide fine-grained control over file permissions, enhancing security
by limiting access to sensitive files.
2. Encryption:
o Description: Converts data into an unreadable format for unauthorized users.
o Evaluation: Encryption is a powerful tool for protecting data confidentiality, both at rest
and in transit. It requires careful management of encryption keys to avoid data loss.
3. File Permissions and Attributes:
o Description: Basic permissions (e.g., read, write, execute) are set for users, groups, and
others.
o Evaluation: File permissions are a simple yet effective way to control access. They need
to be properly configured and maintained to avoid security vulnerabilities.
4. Auditing and Logging:
o Description: Tracks and records file access and modification activities.
o Evaluation: Auditing helps detect and respond to suspicious activities. Regular review of
logs is essential to identify potential security breaches.
5. Backup and Recovery:
o Description: Regularly creating copies of data to restore in case of data loss or
corruption.
o Evaluation: Backup and recovery solutions are critical for data availability. They provide
a safety net against data loss due to accidental deletion, hardware failure, or cyber-
attacks.
6. User and Group Management:
o Description: Organizing users into groups to simplify permission management.
o Evaluation: Effective user and group management streamlines the assignment of
permissions and reduces the complexity of managing large numbers of users.

Overall Evaluation

Effectiveness:

 A well-designed file system protection strategy effectively prevents unauthorized access and
data breaches, ensuring data confidentiality, integrity, and availability.
 Regular audits and updates to access controls and policies enhance security.
Performance Impact:

 Security measures like encryption can impact system performance. Balancing security with
system performance is crucial for efficiency.
 Advanced security measures might introduce latency but are necessary for protecting sensitive
data.

Usability:

 Protection mechanisms should be user-friendly and not overly complex. Users should easily
understand and manage permissions and security settings.
 Excessive complexity can lead to misconfigurations and security loopholes.

Scalability:

 The protection system should scale with the growing number of users and files. Efficient
management tools and automation help in maintaining security at scale.
 As organizations grow, scalable security measures are essential to maintain a secure
environment without compromising on performance.

In conclusion, file system protection is integral to maintaining the security and reliability of data
within an organization. By achieving the goals of confidentiality, integrity, availability, and
proper authentication and authorization, organizations can safeguard their data against a wide
range of threats and ensure it remains accessible and accurate for authorized users.

You might also like