Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
9 views30 pages

Uni 6 File Os

Operating system information basics, algorithms, priority based algorithms, uses and applications, etc.

Uploaded by

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

Uni 6 File Os

Operating system information basics, algorithms, priority based algorithms, uses and applications, etc.

Uploaded by

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

File Systems in Operating System

A computer file is defined as a medium used for saving and managing


data in the computer system. The data stored in the computer system is
completely in digital format, although there can be various types of files
that help us to store the data.

File systems are a crucial part of any operating system, providing a


structured way to store, organize, and manage data on storage devices
such as hard drives, SSDs, and USB drives. Essentially, a file system acts
as a bridge between the operating system and the physical storage
hardware, allowing users and applications to create, read, update, and
delete files in an organized and efficient manner.

What is a File System?

A file system is a method an operating system uses to store, organize, and


manage files and directories on a storage device. Some common types of
file systems include:

 FAT (File Allocation Table): An older file system used by older


versions of Windows and other operating systems.

 NTFS (New Technology File System): A modern file system used


by Windows. It supports features such as file and folder permissions,
compression, and encryption.

 ext (Extended File System): A file system commonly used


on Linux and Unix-based operating systems.

 HFS (Hierarchical File System): A file system used by macOS.

 APFS (Apple File System): A new file system introduced by Apple


for their Macs and iOS devices.

A file is a collection of related information that is recorded on secondary


storage. Or file is a collection of logically related entities. From the user’s
perspective, a file is the smallest allotment of logical secondary storage.

The name of the file is divided into two parts as shown below:

 Name

 Extension, separated by a period.

Issues Handled By File System

We’ve seen a variety of data structures where the file could be kept. The
file system’s job is to keep the files organized in the best way possible.
A free space is created on the hard drive whenever a file is deleted from
it. To reallocate them to other files, many of these spaces may need to be
recovered. Choosing where to store the files on the hard disc is the main
issue with files one block may or may not be used to store a file. It may be
kept in the disk’s non-contiguous blocks. We must keep track of all the
blocks where the files are partially located.

Files Attributes And Their Operations

File Types and Their Content


File Directories

The collection of files is a file directory. The directory contains information


about the files, including attributes, location, and ownership. Much of this
information, especially that is concerned with storage, is managed by the
operating system. The directory is itself a file, accessible by various file
management routines.

Below are information contained in a device directory.

 Name

 Type

 Address

 Current length

 Maximum length

 Date last accessed

 Date last updated

 Owner id

 Protection information

The operation performed on the directory are:

 Search for a file

 Create a file

 Delete a file

 List a directory

 Rename a file

 Traverse the file system

Advantages of Maintaining Directories

 Efficiency: A file can be located more quickly.

 Naming: It becomes convenient for users as two users can have


same name for different files or may have different name for same
file.
 Grouping: Logical grouping of files can be done by properties e.g.
all java programs, all games etc.

Single-Level Directory

In this, a single directory is maintained for all the users.

 Naming Problem: Users cannot have the same name for two files.

 Grouping Problem: Users cannot group files according to their


needs.

Two-Level Directory

In this separate directories for each user is maintained.

 Path Name: Due to two levels there is a path name for every file to
locate that file.

 Now, we can have the same file name for different users.

 Searching is efficient in this method.

Tree-Structured Directory
The directory is maintained in the form of a tree. Searching is efficient and
also there is grouping capability. We have absolute or relative path name
for a file.

File Allocation Methods

There are several types of file allocation methods. These are mentioned
below.

 Continuous Allocation

 Linked Allocation(Non-contiguous allocation)

 Indexed Allocation

Continuous Allocation

A single continuous set of blocks is allocated to a file at the time of file


creation. Thus, this is a pre-allocation strategy, using variable size
portions. The file allocation table needs just a single entry for each file,
showing the starting block and the length of the file. This method is best
from the point of view of the individual sequential file. Multiple blocks can
be read in at a time to improve I/O performance for sequential processing.
It is also easy to retrieve a single block. For example, if a file starts at
block b, and the ith block of the file is wanted, its location on secondary
storage is simply b+i-1.
Disadvantages of Continuous Allocation

 External fragmentation will occur, making it difficult to find


contiguous blocks of space of sufficient length. A compaction
algorithm will be necessary to free up additional space on the disk.

 Also, with pre-allocation, it is necessary to declare the size of the file


at the time of creation.

Linked Allocation(Non-Contiguous Allocation)

Allocation is on an individual block basis. Each block contains a pointer to


the next block in the chain. Again the file table needs just a single entry
for each file, showing the starting block and the length of the file.
Although pre-allocation is possible, it is more common simply to allocate
blocks as needed. Any free block can be added to the chain. The blocks
need not be continuous. An increase in file size is always possible if a free
disk block is available. There is no external fragmentation because only
one block at a time is needed but there can be internal fragmentation but
it exists only in the last disk block of the file.
Disadvantage Linked Allocation(Non-contiguous allocation)

 Internal fragmentation exists in the last disk block of the file.

 There is an overhead of maintaining the pointer in every disk block.

 If the pointer of any disk block is lost, the file will be truncated.

 It supports only the sequential access of files.

Indexed Allocation

It addresses many of the problems of contiguous and chained allocation.


In this case, the file allocation table contains a separate one-level index
for each file: The index has one entry for each block allocated to the file.
The allocation may be on the basis of fixed-size blocks or variable-sized
blocks. Allocation by blocks eliminates external fragmentation, whereas
allocation by variable-size blocks improves locality. This allocation
technique supports both sequential and direct access to the file and thus
is the most popular form of file allocation.
Disk Free Space Management

Just as the space that is allocated to files must be managed, so the space
that is not currently allocated to any file must be managed. To perform
any of the file allocation techniques, it is necessary to know what blocks
on the disk are available. Thus we need a disk allocation table in addition
to a file allocation table. The following are the approaches used for free
space management.

 Bit Tables: This method uses a vector containing one bit for each
block on the disk. Each entry for a 0 corresponds to a free block and
each 1 corresponds to a block in use.
For example 00011010111100110001
In this vector every bit corresponds to a particular block and 0
implies that that particular block is free and 1 implies that the block
is already occupied. A bit table has the advantage that it is relatively
easy to find one or a contiguous group of free blocks. Thus, a bit
table works well with any of the file allocation methods. Another
advantage is that it is as small as possible.

 Free Block List: In this method, each block is assigned a number


sequentially and the list of the numbers of all free blocks is
maintained in a reserved block of the disk.
Advantages of File System

 Organization: A file system allows files to be organized into


directories and subdirectories, making it easier to manage and
locate files.

 Data Protection: File systems often include features such as file


and folder permissions, backup and restore, and error detection and
correction, to protect data from loss or corruption.

 Improved Performance: A well-designed file system can improve


the performance of reading and writing data by organizing it
efficiently on disk.

Disadvantages of File System

 Compatibility Issues: Different file systems may not be


compatible with each other, making it difficult to transfer data
between different operating systems.

 Disk Space Overhead: File systems may use some disk space to
store metadata and other overhead information, reducing the
amount of space available for user data.
 Vulnerability: File systems can be vulnerable to data
corruption, malware, and other security threats, which can
compromise the stability and security of the system.

File Allocation Methods


The allocation methods define how the files are stored in the disk blocks.
There are three main disk space or file allocation methods.

 Contiguous Allocation

 Linked Allocation

 Indexed Allocation

The main idea behind these methods is to provide:

 Efficient disk space utilization.

 Fast access to the file blocks.

All the three methods have their own advantages and disadvantages as
discussed below:

1. Contiguous Allocation

In this scheme, each file occupies a contiguous set of blocks on the disk.
For example, if a file requires n blocks and is given a block b as the
starting location, then the blocks assigned to the file will be: b, b+1, b+2,
……b+n-1. This means that given the starting block address and the
length of the file (in terms of blocks required), we can determine the
blocks occupied by the file.
The directory entry for a file with contiguous allocation contains

 Address of starting block

 Length of the allocated portion.

The file ‘mail’ in the following figure starts from the block 19 with length =
6 blocks. Therefore, it occupies 19, 20, 21, 22, 23, 24 blocks.
Advantages:

 Both the Sequential and Direct Accesses are supported by this. For
direct access, the address of the kth block of the file which starts at
block b can easily be obtained as (b+k).

 This is extremely fast since the number of seeks are minimal


because of contiguous allocation of file blocks.

Disadvantages:

 This method suffers from both internal and external fragmentation.


This makes it inefficient in terms of memory utilization.

 Increasing file size is difficult because it depends on the availability


of contiguous memory at a particular instance.

2. Linked List Allocation

In this scheme, each file is a linked list of disk blocks which need not
be contiguous. The disk blocks can be scattered anywhere on the disk.
The directory entry contains a pointer to the starting and the ending file
block. Each block contains a pointer to the next block occupied by the file.

The file ‘jeep’ in following image shows how the blocks are randomly
distributed. The last block (25) contains -1 indicating a null pointer and
does not point to any other block.

Advantages:

 This is very flexible in terms of file size. File size can be increased
easily since the system does not have to look for a contiguous
chunk of memory.

 This method does not suffer from external fragmentation. This


makes it relatively better in terms of memory utilization.

Disadvantages:

 Because the file blocks are distributed randomly on the disk, a large
number of seeks are needed to access every block individually. This
makes linked allocation slower.

 It does not support random or direct access. We can not directly


access the blocks of a file. A block k of a file can be accessed by
traversing k blocks sequentially (sequential access ) from the
starting block of the file via block pointers.

 Pointers required in the linked allocation incur some extra overhead.

3. Indexed Allocation

In this scheme, a special block known as the Index block contains the
pointers to all the blocks occupied by a file. Each file has its own index
block. The ith entry in the index block contains the disk address of the ith
file block. The directory entry contains the address of the index block as
shown in the image:

Advantages:

 This supports direct access to the blocks occupied by the file and
therefore provides fast access to the file blocks.

 It overcomes the problem of external fragmentation.

Disadvantages:

 The pointer overhead for indexed allocation is greater than linked


allocation.

 For very small files, say files that expand only 2-3 blocks, the
indexed allocation would keep one entire block (index block) for the
pointers which is inefficient in terms of memory utilization. However,
in linked allocation we lose the space of only 1 pointer per block.

For files that are very large, single index block may not be able to hold all
the pointers.
Following mechanisms can be used to resolve this:
1. Linked scheme: This scheme links two or more index blocks
together for holding the pointers. Every index block would then
contain a pointer or the address to the next index block.

2. Multilevel index: In this policy, a first level index block is used to


point to the second level index blocks which inturn points to the disk
blocks occupied by the file. This can be extended to 3 or more levels
depending on the maximum file size.

3. Combined Scheme: In this scheme, a special block called


the Inode (information Node) contains all the information about
the file such as the name, size, authority, etc and the remaining
space of Inode is used to store the Disk Block addresses which
contain the actual file as shown in the image below. The first few of
these pointers in Inode point to the direct blocks i.e the pointers
contain the addresses of the disk blocks that contain data of the file.
The next few pointers point to indirect blocks. Indirect blocks may
be single indirect, double indirect or triple indirect. Single Indirect
block is the disk block that does not contain the file data but the
disk address of the blocks that contain the file data.
Similarly, double indirect blocks do not contain the file data but
the disk address of the blocks that contain the address of the blocks
containing the file data.
Free Space Management in Operating System
Free space management is a critical aspect of operating systems as it
involves managing the available storage space on the hard disk or other
secondary storage devices. The operating system uses various techniques
to manage free space and optimize the use of storage devices. Here are
some of the commonly used free space management techniques:

Free Space Management Techniques

 Linked Allocation: In this technique, each file is represented by a


linked list of disk blocks. When a file is created, the operating
system finds enough free space on the disk and links the blocks of
the file to form a chain. This method is simple to implement but can
lead to fragmentation and waste of space.

 Contiguous Allocation: In this technique, each file is stored as a


contiguous block of disk space. When a file is created, the operating
system finds a contiguous block of free space and assigns it to the
file. This method is efficient as it minimizes fragmentation but
suffers from the problem of external fragmentation.

 Indexed Allocation: In this technique, a separate index block is


used to store the addresses of all the disk blocks that make up a file.
When a file is created, the operating system creates an index block
and stores the addresses of all the blocks in the file. This method is
efficient in terms of storage space and minimizes fragmentation.

 File Allocation Table (FAT): In this technique, the operating


system uses a file allocation table to keep track of the location of
each file on the disk. When a file is created, the operating system
updates the file allocation table with the address of the disk blocks
that make up the file. This method is widely used in Microsoft
Windows operating systems.

 Volume Shadow Copy: This is a technology used in Microsoft


Windows operating systems to create backup copies of files or entire
volumes. When a file is modified, the operating system creates a
shadow copy of the file and stores it in a separate location. This
method is useful for data recovery and protection against accidental
file deletion.

Overall, free space management is a crucial function of operating


systems, as it ensures that storage devices are utilized efficiently and
effectively.
The system keeps tracks of the free disk blocks for allocating space to files
when they are created. Also, to reuse the space released from deleting the
files, free space management becomes crucial. The system maintains a
free space list which keeps track of the disk blocks that are not allocated
to some file or directory. The free space list can be implemented mainly
as:

1. Bitmap or Bit vector

A Bitmap or Bit Vector is series or collection of bits where each bit


corresponds to a disk block. The bit can take two values: 0 and 1: 0
indicates that the block is free and 1 indicates an allocated block. The
given instance of disk blocks on the disk in Figure 1 (where green blocks
are allocated) can be represented by a bitmap of 16 bits

as: 1111000111111001.

Advantages:

 Simple to understand.

 Finding the first free block is efficient. It requires scanning the words
(a group of 8 bits) in a bitmap for a non-zero word. (A 0-valued word
has all bits 0). The first free block is then found by scanning for the
first 1 bit in the non-zero word.

Disadvantages:

 For finding a free block, Operating System needs to iterate all the
blocks which is time consuming.
 The efficiency of this method reduces as the disk size increases.

2. Linked List

In this approach, the free disk blocks are linked together i.e. a free block
contains a pointer to the next free block. The block number of the very
first disk block is stored at a separate location on disk and is also cached

in memory.

In Figure-2, the free space list head points to Block 5 which points to Block
6, the next free block and so on. The last free block would contain a null
pointer indicating the end of free list. A drawback of this method is the I/O
required for free space list traversal.

Advantages:

 The total available space is used efficiently using this method.

 Dynamic allocation in Linked List is easy, thus can add the space as
per the requirement dynamically.

Disadvantages:

 When the size of Linked List increases, the headache of miniating


pointers is also increases.

 This method is not efficient during iteration of each block of


memory.

Grouping
This approach stores the address of the free blocks in the first free block.
The first free block stores the address of some, say n free blocks. Out of
these n blocks, the first n-1 blocks are actually free and the last block
contains the address of next free n blocks. An advantage of this
approach is that the addresses of a group of free disk blocks can be found
easily.

Advantage:

 Finding free blocks in massive amount can be done easily using this
method.

Disadvantage:

 The only disadvantage is, we need to alter the entire list, if any of
the block of the list is occupied.

Counting

This approach stores the address of the first free disk block and a number
n of free contiguous disk blocks that follow the first block. Every entry in
the list would contain:

 Address of first free disk block.

 A number n.

Advantages:

 Using this method, a group of entire free blocks can take place
easily and Fastly.

 The list formed in this method is especially smaller in size.

Disadvantage:

 The first free block in this method, keeps account of other free
blocks. Thus, due to that one block the space requirement is more.

Advantages of Free Space Management Techniques

 Efficient Use of Storage Space: Free space management


techniques help to optimize the use of storage space on the hard
disk or other secondary storage devices.

 Easy to Implement: Some techniques, such as linked allocation,


are simple to implement and require less overhead in terms of
processing and memory resources.

 Faster Access to Files: Techniques such as contiguous allocation


can help to reduce disk fragmentation and improve access time to
files.
Disadvantages of Free Space Management Techniques

 Fragmentation: Techniques such as linked allocation can lead to


fragmentation of disk space, which can decrease the efficiency of
storage devices.

 Overhead: Some techniques, such as indexed allocation, require


additional overhead in terms of memory and processing resources to
maintain index blocks.

 Limited scalability: Some techniques, such as FAT, have limited


scalability in terms of the number of files that can be stored on the
disk.

 Risk of data loss: In some cases, such as with contiguous


allocation, if a file becomes corrupted or damaged, it may be
difficult to recover the data.

 Overall, the choice of free space management technique depends


on the specific requirements of the operating system and the
storage devices being used. While some techniques may offer
advantages in terms of efficiency and speed, they may also have
limitations and drawbacks that need to be considered.

Disk Scheduling Algorithms


Disk scheduling algorithms are crucial in managing how data is read
from and written to a computer’s hard disk. These algorithms help
determine the order in which disk read and write requests are processed,
significantly impacting the speed and efficiency of data access. Common
disk scheduling methods include First-Come, First-Served (FCFS), Shortest
Seek Time First (SSTF), SCAN, C-SCAN, LOOK, and C-LOOK. By
understanding and implementing these algorithms, we can optimize
system performance and ensure faster data retrieval.

 Disk scheduling is a technique operating systems use to manage the


order in which disk I/O (input/output) requests are processed.

 Disk scheduling is also known as I/O Scheduling.

 The main goals of disk scheduling are to optimize the performance


of disk operations, reduce the time it takes to access data and
improve overall system efficiency.
In this article, we will explore the different types of disk scheduling
algorithms and their functions. By understanding and implementing these
algorithms, we can optimize system performance and ensure faster data
retrieval.

Importance of Disk Scheduling in Operating System

 Multiple I/O requests may arrive by different processes and only one
I/O request can be served at a time by the disk controller. Thus
other I/O requests need to wait in the waiting queue and need to be
scheduled.

 Two or more requests may be far from each other so this can result
in greater disk arm movement.

 Hard drives are one of the slowest parts of the computer system and
thus need to be accessed in an efficient manner.

Key Terms Associated with Disk Scheduling

 Seek Time: Seek time is the time taken to locate the disk arm to a
specified track where the data is to be read or written. So the disk
scheduling algorithm that gives a minimum average seek time is
better.

 Rotational Latency: Rotational Latency is the time taken by the


desired sector of the disk to rotate into a position so that it can
access the read/write heads. So the disk scheduling algorithm that
gives minimum rotational latency is better.

 Transfer Time: Transfer time is the time to transfer the data. It


depends on the rotating speed of the disk and the number of bytes
to be transferred.

 Disk Access Time:

Disk Access Time = Seek Time + Rotational Latency + Transfer Time

Total Seek Time = Total head Movement * Seek Time

Disk Access Time and Disk Response Time


 Disk Response Time: Response Time is the average time spent by
a request waiting to perform its I/O operation. The
average Response time is the response time of all
requests. Variance Response Time is the measure of how individual
requests are serviced with respect to average response time. So the
disk scheduling algorithm that gives minimum variance response
time is better.

Goal of Disk Scheduling Algorithms

 Minimize Seek Time

 Maximize Throughput

 Minimize Latency

 Fairness

 Efficiency in Resource Utilization

Disk Scheduling Algorithms

There are several Disk Several Algorithms. We will discuss in detail each
one of them.

 FCFS (First Come First Serve)

 SSTF (Shortest Seek Time First)

 SCAN

 C-SCAN

 LOOK

 C-LOOK

 RSS (Random Scheduling)

 LIFO (Last-In First-Out)

 N-STEP SCAN

 F-SCAN

1. FCFS (First Come First Serve)

FCFS is the simplest of all Disk Scheduling Algorithms. In FCFS, the


requests are addressed in the order they arrive in the disk queue. Let us
understand this with the help of an example.
First Come First Serve

Example:

Suppose the order of request is- (82,170,43,140,24,16,190)


And current position of Read/Write head is: 50

So, total overhead movement (total distance covered by the disk arm) =
(82-50)+(170-82)+(170-43)+(140-43)+(140-24)+(24-16)+(190-16) =642

Advantages of FCFS

Here are some of the advantages of First Come First Serve.

 Every request gets a fair chance

 No indefinite postponement

Disadvantages of FCFS

Here are some of the disadvantages of First Come First Serve.

 Does not try to optimize seek time

 May not provide the best possible service

2. SSTF (Shortest Seek Time First)

In SSTF (Shortest Seek Time First), requests having the shortest seek time
are executed first. So, the seek time of every request is calculated in
advance in the queue and then they are scheduled according to their
calculated seek time. As a result, the request near the disk arm will get
executed first. SSTF is certainly an improvement over FCFS as it decreases
the average response time and increases the throughput of the system.
Let us understand this with the help of an example.

Example:

Shortest Seek Time First

Suppose the order of request is- (82,170,43,140,24,16,190)


And current position of Read/Write head is: 50

So,

total overhead movement (total distance covered by the disk arm) =


(50-43)+(43-24)+(24-16)+(82-16)+(140-82)+(170-140)+(190-170) =208

Advantages of Shortest Seek Time First

Here are some of the advantages of Shortest Seek Time First.

 The average Response Time decreases

 Throughput increases

Disadvantages of Shortest Seek Time First

Here are some of the disadvantages of Shortest Seek Time First.

 Overhead to calculate seek time in advance

 Can cause Starvation for a request if it has a higher seek time as


compared to incoming requests

 The high variance of response time as SSTF favors only some


requests
3. SCAN

In the SCAN algorithm the disk arm moves in a particular direction and
services the requests coming in its path and after reaching the end of the
disk, it reverses its direction and again services the request arriving in its
path. So, this algorithm works as an elevator and is hence also known as
an elevator algorithm. As a result, the requests at the midrange are
serviced more and those arriving behind the disk arm will have to wait.

Example:

SCAN Algorithm

Suppose the requests to be addressed are-82,170,43,140,24,16,190. And


the Read/Write arm is at 50, and it is also given that the disk arm should
move “towards the larger value”.

Therefore, the total overhead movement (total distance covered by the


disk arm) is calculated as

= (199-50) + (199-16) = 332

Advantages of SCAN Algorithm

Here are some of the advantages of the SCAN Algorithm.

 High throughput

 Low variance of response time

 Average response time

Disadvantages of SCAN Algorithm

Here are some of the disadvantages of the SCAN Algorithm.


 Long waiting time for requests for locations just visited by disk arm

4. C-SCAN

In the SCAN algorithm, the disk arm again scans the path that has been
scanned, after reversing its direction. So, it may be possible that too many
requests are waiting at the other end or there may be zero or few requests
pending at the scanned area.

These situations are avoided in the CSCAN algorithm in which the disk
arm instead of reversing its direction goes to the other end of the disk and
starts servicing the requests from there. So, the disk arm moves in a
circular fashion and this algorithm is also similar to the SCAN algorithm
hence it is known as C-SCAN (Circular SCAN).

Example:

Circular SCAN

Suppose the requests to be addressed are-82,170,43,140,24,16,190. And


the Read/Write arm is at 50, and it is also given that the disk arm should
move “towards the larger value”.

So, the total overhead movement (total distance covered by the disk arm)
is calculated as:

=(199-50) + (199-0) + (43-0) = 391

Advantages of C-SCAN Algorithm


Here are some of the advantages of C-SCAN.

 Provides more uniform wait time compared to SCAN.

5. LOOK

LOOK Algorithm is similar to the SCAN disk scheduling algorithm except


for the difference that the disk arm in spite of going to the end of the disk
goes only to the last request to be serviced in front of the head and then
reverses its direction from there only. Thus it prevents the extra delay
which occurred due to unnecessary traversal to the end of the disk.

Example:

LOOK Algorithm

Suppose the requests to be addressed are-82,170,43,140,24,16,190. And


the Read/Write arm is at 50, and it is also given that the disk arm should
move “towards the larger value”.

So, the total overhead movement (total distance covered by the disk arm)
is calculated as:

= (190-50) + (190-16) = 314

6. C-LOOK

As LOOK is similar to the SCAN algorithm, in a similar way, C-LOOK is


similar to the CSCAN disk scheduling algorithm. In CLOOK, the disk arm in
spite of going to the end goes only to the last request to be serviced in
front of the head and then from there goes to the other end’s last request.
Thus, it also prevents the extra delay which occurred due to unnecessary
traversal to the end of the disk.
Example:

1. Suppose the requests to be addressed are-82,170,43,140,24,16,190.


And the Read/Write arm is at 50, and it is also given that the disk
arm should move “towards the larger value”

C-LOOK

So, the total overhead movement (total distance covered by the disk arm)
is calculated as

= (190-50) + (190-16) + (43-16) = 341

7. RSS (Random Scheduling)

It stands for Random Scheduling and just like its name it is natural. It is
used in situations where scheduling involves random attributes such as
random processing time, random due dates, random weights, and
stochastic machine breakdowns this algorithm sits perfectly. Which is why
it is usually used for analysis and simulation.

8. LIFO (Last-In First-Out)

In LIFO (Last In, First Out) algorithm, the newest jobs are serviced before
the existing ones i.e. in order of requests that get serviced the job that is
newest or last entered is serviced first, and then the rest in the same
order.

Advantages of LIFO (Last-In First-Out)

Here are some of the advantages of the Last In First Out Algorithm.
 Maximizes locality and resource utilization

 Can seem a little unfair to other requests and if new requests keep
coming in, it cause starvation to the old and existing ones.

9. N-STEP SCAN

It is also known as the N-STEP LOOK algorithm. In this, a buffer is created


for N requests. All requests belonging to a buffer will be serviced in one
go. Also once the buffer is full no new requests are kept in this buffer and
are sent to another one. Now, when these N requests are serviced, the
time comes for another top N request and this way all get requests to get
a guaranteed service

Advantages of N-STEP SCAN

Here are some of the advantages of the N-Step Algorithm.

 It eliminates the starvation of requests completely

10. F-SCAN

This algorithm uses two sub-queues. During the scan, all requests in the
first queue are serviced and the new incoming requests are added to the
second queue. All new requests are kept on halt until the existing requests
in the first queue are serviced.

Advantages of F-SCAN

Here are some of the advantages of the F-SCAN Algorithm.

 F-SCAN along with N-Step-SCAN prevents “arm stickiness”


(phenomena in I/O scheduling where the scheduling algorithm
continues to service requests at or near the current sector and thus
prevents any seeking)

Each algorithm is unique in its own way. Overall Performance depends on


the number and type of requests.

Note: Average Rotational latency is generally taken as 1/2(Rotational


latency).

Questions For Practice

1. Suppose a disk has 201 cylinders, numbered from 0 to 200. At


some time the disk arm is at cylinder 100, and there is a queue of
disk access requests for cylinders 30, 85, 90, 100, 105, 110, 135,
and 145. If Shortest-Seek Time First (SSTF) is being used for
scheduling the disk access, the request for cylinder 90 is serviced
after servicing ____________ the number of requests.
(A) 1

(B) 2

(C) 3

(D) 4

Solution: Correct Answer is (C).

2) Consider an operating system capable of loading and executing


a single sequential user process at a time. The disk head
scheduling algorithm used is First Come First Served (FCFS). If
FCFS is replaced by Shortest Seek Time First (SSTF), claimed by
the vendor to give 50% better benchmark results, what is the
expected improvement in the I/O performance of user programs?

(A) 50%

(B) 40%

(C) 25%

(D) 0%

Solution: Correct Answer is (D).

3) Suppose the following disk request sequence (track numbers)


for a disk with 100 tracks is given: 45, 20, 90, 10, 50, 60, 80, 25,
70. Assume that the initial position of the R/W head is on track
50. The additional distance that will be traversed by the R/W head
when the Shortest Seek Time First (SSTF) algorithm is used
compared to the SCAN (Elevator) algorithm (assuming that SCAN
algorithm moves towards 100 when it starts execution) is _________
tracks.

(A) 8

(B) 9

(C) 10

(D) 11

Solution: Correct Answer is (C).

4) Consider a typical disk that rotates at 15000 rotations per


minute (RPM) and has a transfer rate of 50 × 10^6 bytes/sec. If
the average seek time of the disk is twice the average rotational
delay and the controller’s transfer time is 10 times the disk
transfer time, the average time (in milliseconds) to read or write
a 512-byte sector of the disk is _____________.
Solution: Correct Answer is 6.1

You might also like