Wa0047.
Wa0047.
I/O Management
I/O Devices:
1. An input/output (I/O) device is any hardware that
enables the user or another system to
communicate with a computer.
2. These devices can both receive data (input) from
the user or another source and deliver data
(output) from the computer.
3. I/O device bridges the computer and external
entities, facilitating data exchange.
I/O (programmed)
Programmed I/O is one of the three techniques we use for I/O transfer. The other two methods
for the same are interrupted I/O and (direct memory access) DMA.
Programmed I/O is a technique that is used to transfer data between the processor and the I/O
module.
The CPU, initiates the I/O operation and continually checks the status of the I/O device.
The CPU keeps querying the device to see if it's ready.
Since the CPU is busy-waiting, it can't do anything else during this time.
•The CPU issues an I/O command and moves on to do
other work.
•When the I/O device is ready, it sends an interrupt to
notify the CPU.
•The CPU then handles the interrupt via an Interrupt
Service Routine (ISR).
•More efficient use of CPU time, especially for devices
with longer latency.
•Offloads the entire data transfer task to a
DMA controller.
•CPU is not involved in actual data movement,
only sets up the transfer.
•Ideal for high-volume data transfers, like disk or
network I/O.
I/O Buffering
Two types of I/O devices: block oriented and stream 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.
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.
Single Buffer :
The simplest type of support that the operating system can provide is single buffering .
When a user process issues an I/O request, the operating system assigns a buffer in the system
portion of main memory to the operation.
Double buffering
Double buffering involves assigning two system buffers to the operation.
A process now transfers data to (or from) one buffer while the operating system empties (or
fills) the other. This technique is known as double buffering or buffer swapping.
Circular Buffering
A double-buffer scheme should smooth out the flow of data between an I/O device and a process. If
the performance of a particular process is the focus of our concern, i.e. I/O operation has to keep up
with the process.
Double buffering may be inadequate if the process performs rapid bursts of I/O. In this case, the
problem can often be alleviated by using more than two buffers.
Disk Scheduling
Disk Performance Parameters:
The actual details of disk I/O operation depend on the computer system, the operating system, and
the nature of the I/O channel and disk controller hardware.
Disk Structure
1.Platter:
•A disk has one or more circular plates (platters) coated with magnetic m
•Each platter stores data on both sides.
2.Track:
•A track is a circular ring on the surface of the platter.
•Each platter has many tracks, like the rings on a tree trunk.
3.Sector:
•Each track is divided into smaller pieces called sectors.
•A sector is the smallest unit of storage (usually 512 bytes or 4 KB).
4.Read/Write Head:This is the part that reads data from or writes data
to the disk.It floats just above the platter and moves in and out to reach
different tracks.
5.Spindle:The motor that spins the platters .
Disk Scheduling- Algorithms
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.
Eg 1.Suppose the order of request is- (82,170,43,140,24,16,190) And current position of
Read/Write head is: 50
Find total seek count.
Eg.2 Suppose the order of the request is- (56,32,79,14,49,167,133,120)
Shortest Seek Time First
Request sequence = {176, 79, 34, 60, 92, 11, 41, 114}
Initial head position = 50
SCAN(Elevator) Algorithm
Request sequence = {176, 79, 34, 60, 92, 11, 41, 114}
Initial head position = 50
Direction = left (We are moving from right to left)
C-SCAN(Circular Elevator) Algorithm
Request sequence = {176, 79, 34, 60, 92, 11, 41, 114}
Initial head position = 50
Direction = left (We are moving from right to left)
File Management
Overview–File and File Systems
The file system provides the resource abstractions typically associated with secondary storage.
The file system permits users to create data collections, called files, with desirable properties,
such as
• Long-term existence: Files are stored on disk or other secondary storage and do not disappear
when a user logs off.
• Sharable between processes: Files have names and can have associated access permissions
that permit controlled sharing.
• Structure: Depending on the file system, a file can have an internal structurethat is convenient
for particular applications. In addition, files can be organized into hierarchical or more complex
structure to reflect the relationships among files.
File system provides not only a means to store data organized as files.
Operations on files
Create: A new file is defined and positioned within the structure of files.
Delete: A file is removed from the file structure and destroyed.
Open: An existing file is declared to be “opened” by a process, allowing the process to perform
functions on the file.
Close:The file is closed with respect to a process, so that the process no longer may perform
functions on the file, until the process opens the file again.
Read:A process reads all or a portion of the data in a file.
Write: A process updates a file, either by adding new data that expands the size of the file or by
changing the values of existing data items in the file.
Field :Afield is the basic element of data.An individual field contains a single value, such as an
employee’s last name,a date
Record :Arecord is a collection of related fields that can be treated as a unit by some application
program. For example, an employee record would contain such fields as name, social security
number, job classification, etc.
File :Afile is a collection of similar records. The file is treated as a single entity by users and
applications and may be referenced by name. Files have file names and may be created and
deleted. Access control restrictions usually apply at the file level.
Database:A database is a collection of related data. The essential aspects of a database are that
the relationships that exist among elements of data are explicit and that the database is
designed for use by a number of different applications. A database may contain all of the
information related to an organization or project, such as a business or a scientific study.
Objectives for a file management system:
• To meet the data management needs and requirements of the user, which include storage of
data and the ability to perform the aforementioned operations
• To guarantee, to the extent possible, that the data in the file are valid.
• To optimize performance, both from the system point of view in terms of overall throughput
and from the user’s point of view in terms of response time
• To provide I/O support for a variety of storage device types.
• To minimize or eliminate the potential for lost or destroyed data.
• To provide a standardized set of I/O interface routines to user processes.
• To provide I/O support for multiple users, in the case of multiple-user systems.
File organization to refer to the logical structuring of the records as determined by the way in
which they are accessed.
For file organization the following criteria are important:
• Short access time
• Ease of update
• Economy of storage
• Simple maintenance
• Reliability
File Directory
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.
The directory is itself a file, accessible by various file management routines.
Operations that may be performed on
the directory:
• Search: When a user or application references a file, the directory must be searched to find
the entry corresponding to that file.
• Create file: When a new file is created,an entry must be added to the directory.
• Delete file: When a file is deleted,an entry must be removed from the directory.
• List directory: All or a portion of the directory may be requested. Generally, this request is
made by a user and results in a listing of all files owned by that user, plus some of the attributes
of each file (e.g., type, access control information, usage information).
• Update directory: Because some file attributes are stored in the directory, a change in one of
these attributes requires a change in the corresponding directory entry.
Directory Structure
There's a master directory at the top (like C:\
on Windows or / on Linux).Under the master
directory, you can have subdirectories.Each
subdirectory can contain files or more
subdirectories. This creates a tree-like
structure.
File Sharing
Two issues needs to be addressed in file sharing: access rights and the
management of simultaneous access.
Access Rights: the access rights can be assigned to particular users.
None: The user may not even learn of the existence of the file, much less access
it. To enforce this restriction, the user would not be allowed to read the user
directory that includes this file.
• Knowledge: The user can determine that the file exists and who its owner is.
The user is then able to petition the owner for additional access rights.
• Execution: The user can load and execute a program but cannot copy it.
Proprietary programs are often made accessible with this restriction.
• Reading: The user can read the file for any purpose.
• Appending: The user can add data to the file, often only at the end.