0% found this document useful (0 votes)
28 views98 pages

Unit 5

The document provides an overview of input/output (I/O) devices in computer systems, categorizing them into input devices, output devices, block devices, and character devices. It discusses the Application I/O Interface, which standardizes access to various devices through device drivers, and explains the differences between blocking and non-blocking I/O operations. Additionally, it covers network devices, clocks and timers, and the importance of asynchronous I/O for efficient processing.

Uploaded by

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

Unit 5

The document provides an overview of input/output (I/O) devices in computer systems, categorizing them into input devices, output devices, block devices, and character devices. It discusses the Application I/O Interface, which standardizes access to various devices through device drivers, and explains the differences between blocking and non-blocking I/O operations. Additionally, it covers network devices, clocks and timers, and the importance of asynchronous I/O for efficient processing.

Uploaded by

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

APPLICATION I/O INTERFACE

Input/output devices are the devices that are responsible for the input/output operations in a
computer system.

 An input device is any hardware device that sends data to a computer, allowing you to
interact with and control the computer. An input device can send data to another device
but it cannot receive data from another device. Examples of input devices are mouse,
keyboard, scanner etc
 An output device is any peripheral that receives data from a computer, usually for
display, projection. An output device can receive data from another device, but it cannot
send data to another device. Examples of output devices are printer, monitor, projector
etc.
 Basically there are following two types of input/output devices:
1. Block devices
2. Character devices

Block Devices
 Block device stores information in block with fixed-size and own-address. A Block
Device is a device whose driver communicates by sending entire blocks of data.
 It is possible to read/write each and every block independently in case of block device.
 In case of disk, it is always possible to seek another cylinder and then wait for required
block to rotate under head without mattering where the arm currently is. Therefore, disk
is a block addressable device. Example - hard disks, USB cameras, Disk-On-Key.
Character Devices
 A character device accepts/delivers a stream of characters without regarding to any
block structure. A Character Device is a device whose driver communicates by sending
and receiving single characters (bytes, octets)
 Character device isn't addressable. Character device doesn't have any seek operation.
 There are too many character devices present in a computer system such as - serial ports,
parallel ports, sound cards, keyboard etc .

Application I/O Interface


 Application I/O Interface represents the structuring techniques and interfaces for
the operating system to enable I/O devices to be treated in a standard, uniform way.
 User application access to a wide variety of different devices is accomplished through
layering, and through encapsulating all of the device-specific code into device drivers,
while application layers are presented with a common interface for all ( or at least large
general categories of ) devices.
 Most devices can be characterized as block I/O, character I/O, memory mapped file
access, or network sockets.
 A few devices are special, such as time-of-day clock and the system timer.

1. Block and Character Devices

 Block devices are accessed a block at a time, and are indicated by a "b" as the first
character in a long listing on UNIX systems. Operations supported include read( ),
write( ), and seek( ).
o Accessing blocks on a hard drive directly ( without going through the filesystem
structure ) is called raw I/O, and can speed up certain operations by bypassing the
buffering and locking normally conducted by the OS. ( It then becomes the
application's responsibility to manage those issues. )
o A new alternative is direct I/O, which uses the normal filesystem access, but
which disables buffering and locking operations.
 Memory-mapped file I/O can be layered on top of block-device drivers.
o Rather than reading in the entire file, it is mapped to a range of memory
addresses, and then paged into memory as needed using the virtual memory
system.
o Access to the file is then accomplished through normal memory accesses, rather
than through read( ) and write( ) system calls. This approach is commonly used
for executable program code.
 Character devices are accessed one byte at a time, and are indicated by a "c" in UNIX
long listings. Supported operations include get( ) and put( ), with more advanced
functionality such as reading an entire line supported by higher-level library routines.

2. Network Devices

 Because network access is inherently different from local disk access, most systems
provide a separate interface for network devices.
 One common and popular interface is the socket interface, which acts like a cable or
pipeline connecting two networked entities. Data can be put into the socket at one end,
and read out sequentially at the other end. Sockets are normally full-duplex, allowing for
bi-directional data transfer.
 The select( ) system call allows servers ( or other applications ) to identify sockets which
have data waiting, without having to poll all available sockets.

3. Clocks and Timers

 Three types of time services are commonly needed in modern systems:


o Get the current time of day.
o Get the elapsed time ( system or wall clock ) since a previous event.
o Set a timer to trigger event X at time T.
 Unfortunately time operations are not standard across all systems.
 A programmable interrupt timer, PIT can be used to trigger operations and to measure
elapsed time. It can be set to trigger an interrupt at a specific future time, or to trigger
interrupts periodically on a regular basis.
o The scheduler uses a PIT to trigger interrupts for ending time slices.
o The disk system may use a PIT to schedule periodic maintenance cleanup, such as
flushing buffers to disk.
o Networks use PIT to abort or repeat operations that are taking too long to
complete. I.e. resending packets if an acknowledgement is not received before the
timer goes off.
o More timers than actually exist can be simulated by maintaining an ordered list of
timer events, and setting the physical timer to go off when the next scheduled
event should occur.
 On most systems the system clock is implemented by counting interrupts generated by
the PIT. Unfortunately this is limited in its resolution to the interrupt frequency of the
PIT, and may be subject to some drift over time. An alternate approach is to provide
direct access to a high frequency hardware counter, which provides much higher
resolution and accuracy, but which does not support interrupts.

4. Blocking and Non-blocking I/O

 Most I/O requests are considered blocking requests, meaning that control does not return
to the application until the I/O is complete. ... Blocking I/O system calls (a) do not return
until the I/O is complete. Nonblocking I/O system calls return immediately. The process
is later notified when the I/O is complete
 With blocking I/O a process is moved to the wait queue when an I/O request is made, and
moved back to the ready queue when the request completes, allowing other processes to
run in the meantime.
 With non-blocking I/O the I/O request returns immediately, whether the requested I/O
operation has ( completely ) occurred or not. This allows the process to check for
available data without getting hung completely if it is not there.
 One approach for programmers to implement non-blocking I/O is to have a multi-
threaded application, in which one thread makes blocking I/O calls ( say to read a
keyboard or mouse ), while other threads continue to update the screen or perform other
tasks.
 A subtle variation of the non-blocking I/O is the asynchronous I/O, in which the I/O
request returns immediately allowing the process to continue on with other tasks, and
then the process is notified ( via changing a process variable, or a software interrupt, or a
callback function ) when the I/O operation has completed and the data is available for
use. ( The regular non-blocking I/O returns immediately with whatever results are
available, but does not complete the operation and notify the process later. )
 Asynchronous I/O (also non-sequential I/O) is a form of input/output processing that
permits other processing to continue before the transmission has finished.
 Input and output (I/O) operations on a computer can be extremely slow compared to the
processing of data. An I/O device can incorporate mechanical devices that must
physically move, such as a hard drive seeking a track to read or write; this is often orders
of magnitude slower than the switching of electric current. For example, during a disk
operation that takes ten milliseconds to perform, a processor that is clocked at
one gigahertz could have performed ten million instruction-processing cycles.
 A simple approach to I/O would be to start the access and then wait for it to complete.
But such an approach (called synchronous blocking I/O) would block the progress of a
program while the communication is in progress, leaving system resources idle. When a
program makes many I/O operations (such as a program mainly or largely dependent
on user input), this means that the processor can spend almost all of its time idle waiting
for I/O operations to complete.
 Alternatively, it is possible to start the communication and then perform processing that
does not require that the I/O be completed. This approach is called asynchronous input/
output. Any task that depends on the I/O having completed (this includes both using the
input values and critical operations that claim to assure that a write operation has been
completed) still needs to wait for the I/O operation to complete, and thus is still blocked,
but other processing that does not have a dependency on the I/O operation can continue.
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner

You might also like