Unit 5 I-O Management - Disk Scheduling-File Management
Unit 5 I-O Management - Disk Scheduling-File Management
Unit 5 I-O Management - Disk Scheduling-File Management
⚫ FILE MANAGEMENT
Dr.M.Sujithra
AP/Dept of Computing- Data Science
CIT 1
I/O MANAGEMENT, DISK SCHEDULING
2
Categories of I/O
Devices
External devices that engage in I/O with computer
systems can be grouped into three categories:
Differences in I/O
Devices
Data Rate
Application
Complexity of Control
Unit of Transfer
Data Representation
Error Conditions
Differences in I/O
Devices
■ Devices differ in a number of areas:
Organization of the I/O
Function
■ Three techniques for performing I/O are:
■ Programmed I/O
■ the processor issues an I/O command on behalf of a process to an I/O
module; that process then busy waits for the operation to be completed
before proceeding
■ Interrupt-driven I/O
■ the processor issues an I/O command on behalf of a process
■ if non-blocking – processor continues to execute instructions from
the process that issued the I/O command
■ if blocking – the next instruction the processor executes is from the
OS, which will put the current process in a blocked state and schedule
another process
⚫Whether a read or write is requested, using the read or write control line
between the processor and the DMA module
⚫The address of the I/O device involved, communicated on the data lines
9
10
11
OPERATING SYSTEM DESIGN ISSUES
⚫ Design Objectives
Two objectives are paramount in designing the
I/O facility:
⚫ Efficiency :
⚫ Efficiency is important because I/O operations often form a
bottleneck in a computing system.
⚫ One way to tackle this problem is multiprogramming
⚫ Swapping is used to bring in additional ready processes to keep the
processor busy, but this in itself is an I/O operation
⚫ Generality:
⚫ it is desirable to handle all devices in a uniform manner
12
Logical Structure of the I/O Function
⚫ Logical I/O: Concerned with managing general I/O functions on behalf
of user processes, allowing them to deal with the device in terms of a
device identifier and simple commands: Open, Close, Read, and Write.
⚫ Device I/O: The requested operations and data are converted into
appropriate sequence of I/O instructions. Buffering techniques may be
used to improve use.
⚫ Scheduling and control: The actual queuing and scheduling of I/O
operations occurs at this level.
⚫ Directory management: Symbolic file names are converted to
identifiers. This level also concerned about user operations that affect
the directory of files, such as Add, Delete, and Reorganize
⚫ File system: Deals with logical structures of files. Open, Close, Read,
Write. Access rights are handled in this level.
⚫ Physical organization: References to files are converted to physical
secondary storage addresses, considering the physical track and sector
structure of file.
14
I/O Buffering
Two types of I/O devices:
Block-oriented
⚫A block-oriented device stores information in blocks that are
usually of fixed size, and transfers are made one block at a time.
⚫Generally, it is possible to reference data by its block number.
⚫Disks and USB keys are examples of block-oriented devices.
Stream-oriented.
⚫A stream-oriented device transfers data in and out as a stream
of bytes, with no block structure.
⚫Terminals, printers, communications ports, mouse and other
pointing devices, and
⚫Most other devices that are not secondary storage are
stream-oriented.
15
I/O Buffering
■ Perform input transfers in advance of requests being made and
perform output transfers some time after the request is made
Block-Oriented Single
Buffer
■ Input transfers are made to the system buffer
■ Disadvantages:
■ complicates the logic in the operating system
■ swapping logic is also affected
Stream-Oriented Single
Buffer
■ Line-at-a-time operation ■ Byte-at-a-time operation
■ appropriate for ■ used on forms-mode
scroll-mode terminals terminals
(dumb terminals) ■ when each keystroke is
■ user input is one line at a significant
time with a carriage return ■ other peripherals such as
signaling the end of a line sensors and controllers
■ output to the terminal is
similarly one line at a time
No
Buffer
■ Without a buffer, the OS directly accesses the device when it
needs
Single Buffer
■ Operating system assigns a buffer in main memory for an I/O
request
■ Use two system buffers instead of
one
Double Buffer
■ A process can transfer data to or
from one buffer
Buffer
unit in a circular buffer
processes.
Disk Scheduling
• Operating System does Disk scheduling to schedule
I/O requests arriving for the disk(I/O scheduling)
• 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 request may be far from each other so
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.
Disk Scheduling
Algorithms
Disk Performance
Parameters
• Seek Time : Time taken in locating the disk arm to a
specified track where the read/write request will be
satisfied.
• Rotational Latency :Time taken by the desired sector to
rotate itself to the position from where it can access the
R/W heads.
• Transfer Time : Time taken to transfer the data.
• Disk Access Time = Rotational Latency + Seek Time +
Transfer Time
• Disk Response Time : Average time spent by each request
waiting for the IO operation.
• Purpose of Disk Scheduling
The main purpose of disk scheduling algorithm is to select
a disk request from the queue of IO requests and decide
the schedule when this request will be processed.
As a result, the requests at the midrange are serviced more and those arriving
behind the disk arm will have to wait.
C-SCAN (Circular SCAN)
In 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 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 it is known
as C-SCAN (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”.
■ During scan, all new requests are put into the other queue
■ A key aspect of I/O is the use of buffers that are controlled by I/O utilities
rather than by application processes
■ The use of buffers also decouples the actual I/O transfer from the address
space of the application process
■ Two of the most widely used approaches are disk scheduling and the disk
cache
■RAID -3 MEMBERS
■WINDOWS - 3 MEMBERS
■WINDOWS FILE SYSTEM - 2 MEMBERS
FILE MANAGEMENT
■ Overview, File Organization and Access, File directories, File sharing,
Secondary Storage Management, Windows file system
FILE MANAGEMENT
File
50
File Operations
■ Close: The file is closed with respect to a process, so the
process no longer may perform functions on the file,
until the process opens the file again.
52
File Attributes
■ Location – pointer to file location on device
57
on.
Database
■ A database is a collection of related data.
■ The database itself consists of one or more
types of files.
■ Usually, there is a separate database
management system that is independent of
the operating system, although that system
may make use of some file management
programs.
File Structure Terms
Field File
■ collection of similar
■ basic element of data records
■ contains a single value ■ treated as a single entity
■ fixed or variable length ■ may be referenced by
name
Database ■ access control restrictions
■ collection of related data Record
usually apply at the file
■ relationships among ■ collection
level of related fields
elements of data are that can be treated as a unit
explicit by some application program
■ designed for use by a
■ One field is the key – a
number of different
unique identifier
applications
■ consists of one or more
File Management
Systems
■ A file management system is that set of system
software that provides services to users and
applications in the use of files.
■ The next level is referred to as the basic file system, or the physical
I/O level. This is the primary interface with the environment
outside of the computer system.
■ It deals with blocks of data that are exchanged with disk or tape
system
■ The basic I/O supervisor is responsible for all file I/O initiation and
termination.
■ • Ease of update
■ • Economy of storage
76
Types of operations on the directory
Tree-Structur
ed Directory
■ Master
directory with
user directories
underneath it
■ Each user
directory may
have
subdirectories
and files as
entries
FILE DIRECTORIES
Contents
•Associated with any file management system and collection of files is a file
directory. The directory contains information about the files, including attributes,
location, and ownership.
Structure
•The simplest form of structure for a directory is that of a list of entries, one for
each file. This structure could be represented by a simple sequential file, with the
name of the file serving as the key.
Naming
•Users need to be able to refer to a file by a symbolic name. Clearly, each file in
the system must have a unique name in order that file references be
unambiguous.The series of directory names, culminating in the file name itself,
constitutes a pathname for the file.
File Sharing
In a multiuser system, there is almost always a
requirement for allowing files to be shared among a
number of users.
Two issues arise:
•Access rights and
•Management of simultaneous access.
File Sharing
Access
Rights
■ None ■ Appending
■ the user would not be
allowed to read the user ■ the user can add data to the
directory that includes the file but cannot modify or
file delete any of the file’s
contents
■ Knowledge
■ Updating
■ the user can determine that
the file exists and who its ■ the user can modify, delete,
owner is and can then and add to the file’s data
petition the owner for
additional access rights ■ Changing protection
■ Execution ■ the user can change the
■ the user can load and execute access rights granted to other
a program but cannot copy it users
■ Reading ■ Deletion
■ the user can read the file for ■ the user can delete the file
any purpose, including from the file system
copying and execution
User Access Rights
Simultaneous Access
•When access is granted to append or update a file to
more than one user, the operating system or file
management system must enforce discipline.
• A brute-force approach is to allow a user to lock the
entire file when it is to be updated.
•A finer grain of control is to lock individual records
during update.
•Issues of mutual exclusion and deadlock must be
•addressed in designing the shared access capability.
Secondary storage
management
■ Easy to implement.
92
Contiguous File Allocation
▪A single
contiguous set of
blocks is
allocated to a file
at the time of file
creation
▪Preallocation
strategy using
variable-size
portions
■ No external fragmentation
95
Chained
Allocation
▪Allocation is on an
individual block basis
▪No external
fragmentation to worry
about
12.11
12.12
Indexed Allocation
■ Each file has its own index block which stores the addresses of
disk space occupied by the file.
98
Indexed Allocation with
Block Portions
12.13
Indexed Allocation with
Variable Length Portions
12.14
File Allocation Methods
File Allocation Methods-
Summary
Contiguous Allocation
•Each file occupies a contiguous address space on disk.
•Assigned disk address is in linear order.
•Easy to implement.
•External fragmentation is a major issue with this type of allocation technique.
Linked Allocation
•Each file carries a list of links to disk blocks.
•Directory contains link / pointer to first block of a file.
•No external fragmentation
•Effectively used in sequential access file.
•Inefficient in case of direct access file.
Indexed Allocation
•Provides solutions to problems of contiguous and linked allocation.
•A index block is created having all pointers to files.
•Each file has its own index block which stores the addresses of disk space
occupied by the file.
•Directory contains the addresses of index blocks of files.
103