OS IO Management & Disk Scheduling Unit 5
OS IO Management & Disk Scheduling Unit 5
Scheduling
Introduction
• I/O management and disk scheduling are essential components
of a computer's operating system. I/O management controls
the flow of data into and out of a data processing complex. Disk
scheduling handles the organization and access of data on a disk.
I/O management involves:
• Reading from or writing to devices, such as disks, network
interfaces, or user input/output devices
• Controlling the flow of data into and out of a data processing
complex
• Transferring information between computer memory and the
outside world
Contt.
Disk scheduling involves:
• Determining the order in which the read/write head of
the disk moves to access data
• Ensuring that only one I/O request can be served at a
time by the disk controller
• Handling multiple I/O requests that may arrive by
different processes
• Being written as a separate module of the operating
system, allowing it to be replaced with a different
algorithm if necessary
I/O Devices
• I/O (input/output) devices are hardware that allows
humans or other systems to communicate with a
computer. I/O devices transfer data to and from a
computer.
=(50-45)+(45-21)+(67-21)+(90-67)+(90-4)+(50-
4)+(89-50)+(61- 52)+(87-61)+(87-25)
= 5 + 24 + 46 + 23 + 86 + 46 + 49 + 9 + 26 + 62
= 376
SSTF (shortest seek time first)
algorithm
Shortest seek time first (SSTF) algorithm selects the disk I/O
request which requires the least disk arm movement from its
current position regardless of the direction. It reduces the total
seek time as compared to FCFS.
• It allows the head to move to the closest track in the service
queue.
Disadvantages
• It may cause starvation for some requests.
• Switching direction on the frequent basis slows the working of
algorithm.
• It is not the most optimal algorithm.
Contt.
• Example
Consider the following disk request sequence for a disk
with 100 tracks
45, 21, 67, 90, 4, 89, 52, 61, 87, 25
Head pointer starting at 50. Find the number of head
movements in cylinders using SSTF scheduling.
Number of cylinders =
5 + 7 + 9 + 6 + 20 + 2 + 1 + 65 + 4 + 17 = 136
SCAN and C-SCAN algorithm
• Scan Algorithm
• It is also called as Elevator Algorithm. In this algorithm, the disk
arm moves into a particular direction till the end, satisfying all the
requests coming in its path,and then it turns backand moves in the
reverse direction satisfying requests coming in its path.
• It works in the way an elevator works, elevator moves in a direction
completely till the last floor of that direction and then turns back.
Example
• Consider the following disk request sequence for a disk with 100
tracks
• 98, 137, 122, 183, 14, 133, 65, 78
• Head pointer starting at 54 and moving in left direction. Find the
number of head movements in cylinders using SCAN scheduling.
Contt...
Number of Cylinders = 40 + 14 + 65 + 13 + 20 + 24 + 11 + 4
+ 46 = 237
C-SCAN algorithm
• In C-SCAN algorithm, the arm of the disk moves in a
particular direction servicing requests until it reaches
the last cylinder, then it jumps to the last cylinder of the
opposite direction without servicing any request then it
turns back and start moving in that direction servicing
the remaining requests.
Example
• Consider the following disk request sequence for a disk
with 100 tracks
• 98, 137, 122, 183, 14, 133, 65, 78
• Head pointer starting at 54 and moving in left direction.
Find the number of head movements in cylinders using
C-SCAN scheduling.
Contt..
• 1.Name
• 2.Identifier
• 3.Type
• 4.Location
• 5.Size
• 6.Protection
• 7.Time and Date
Operations on the File
• Create operation:
• Open operation:
• Write operation:
• Read operation:
• Re-position or Seek operation:
• Delete operation:
• Close operation:
• Rename operation:
File Access Methods
• Let's look at various ways to access files stored in secondary memory.
Sequential Access
• Most of the operating systems access the file sequentially. In other
words, we can say that most of the files need to be accessed
sequentially by the operating system.
• In sequential access, the OS read the file word by word. A
pointer is maintained which initially points to the base address of the
file. If the user wants to read first word of the file then the pointer
provides that word to the user and increases its value by 1 word. This
process continues till the end of the file.
• Modern word systems do provide the concept of direct access
and indexed access but the most used method is sequential
access due to the fact that most of the files such as text files,
audio files, video files, etc need to be sequentially accessed.
Contt..
Direct Access
• What is a directory?
• Directory can be defined as the listing of the related
files on the disk. The directory may store some or the
entire file attributes.
• To get the benefit of different file systems on the
different operating systems, A hard disk can be divided
into the number of partitions of different sizes. The
partitions are also called volumes or mini disks.
• Each partition must have at least one directory in which,
all the files of the partition can be listed. A directory
entry is maintained for each file in the directory which
stores all the information related to that file.
• A directory can be viewed as a file which contains the
Meta data of the bunch of files.
Cont..
Single Level Directory
• Checking for consistency and repairing errors: The consistency and error-free operation of files
and directories must be guaranteed by file systems. Journaling, checksumming, and redundancy
are methods for consistency checking and error recovery. File systems may need to perform
recovery operations if errors happen in order to restore lost or damaged data.
• Locking files and managing concurrency: To prevent conflicts and guarantee data integrity, file
systems must control how many processes or users can access a file at once. File locking,
semaphore, and other concurrency-controlling methods are available.
• Performance optimization: File systems need to optimize performance by reducing file access
times, increasing throughput, and minimizing system overhead. Caching, buffering, prefetching,
and parallel processing are methods for improving performance.
Key Steps Involved In File System Implementation
• File system implementation is a crucial component of an operating system, as it provides an interface
between the user and the physical storage device. Here are the key steps involved in file system
implementation:
• Partitioning the storage device: The first step in file system implementation is to partition the physical
storage device into one or more logical partitions. Each partition is formatted with a specific file system that
defines the way files and directories are organized and stored.
• File system structures: File system structures are the data structures used by the operating system to
manage files and directories. Some of the key file system structures include the superblock, i-node table,
directory structure, and file allocation table.
• Allocation of storage space: The file system must allocate storage space for each file and directory on the
storage device. There are several methods for allocating storage space, including contiguous, linked, and
indexed allocation.
• File operations: The file system provides a set of operations that can be performed on files and directories,
including create, delete, read, write, open, close, and seek. These operations are implemented using the file
system structures and the storage allocation methods.
• File system security: The file system must provide security mechanisms to protect files and directories from
unauthorized access or modification. This can be done by setting file permissions, access control lists, or
encryption.
• File system maintenance: The file system must be maintained to ensure efficient and reliable operation.
This includes tasks such as disk defragmentation, disk checking, and backup and recovery.
Protection and Security in Operating
System
• Protection and security requires that computer resources such as CPU, softwares, memory etc.
are protected. This extends to the operating system as well as the data in the system. This can
be done by ensuring integrity, confidentiality and availability in the operating system. The
system must be protect against unauthorized access, viruses, worms etc.
Threats to Protection and Security
• A threat is a program that is malicious in nature and leads to harmful effects for the system. Some of the common threats that occur in
a system are:
Virus
• Viruses are generally small snippets of code embedded in a system. They are very dangerous and can corrupt files, destroy data,
crash systems etc. They can also spread further by replicating themselves as required.
Trojan Horse
• A trojan horse can secretly access the login details of a system. Then a malicious user can use these to enter the system as a
harmless being and wreak havoc.
Trap Door
• A trap door is a security breach that may be present in a system without the knowledge of the users. It can be exploited to
harm the data or files in a system by malicious people.
Worm
• A worm can destroy a system by using its resources to extreme levels. It can generate multiple copies which claim all the
resources and don't allow any other processes to access them. A worm can shut down a whole network in this way.
Denial of Service
• These type of attacks do not allow the legitimate users to access a system. It overwhelms the system with requests so it is
overwhelmed and cannot work properly for other user.
Protection and Security Methods