Principles of
I/O Hardware,
Device
controllers and
Device drivers
OS Assig nment made
by:-
Karandeep Sing h Sehg al
Btech(CSE)-III
A50105220029
Things we will
cover..
Managing I/O is one
of the most important
task of an OS .
• Principles of I/O
hardware.
• Device controllers.
• Device drivers
26/10/2021
PRINCIPLES OF I/O HARDWARE AND
SOFTWARE
2
I/O
Hardware
system
• An I/O system takes an I/O request from the
application and send it to the physical device,
then takes back the response from physical
device to the application.
26/10/2021
PRINCIPLES OF I/O HARDWARE AND
SOFTWARE
3
Block Devices – Type of I/O device in
which the driver communicates by
sending entire blocks of data. For Eg
– HDDs, USB drive.
Character Devices - Type of I/O
device in which the driver
communicates by sending and
receiving single characters. For Eg
– sound cards
• There are mainly two types of I/O devices
Device Controllers …
Device controllers
are basically an
interface between
the device and its
device driver.
It forms the
“electrical-
component” of the
device.
For
communication
with the OS, there
must be a device
controller for the
device.
It converts serial
bit stream to block
of bytes and
perform error
correction, as
necessary.
Any device connected to the
computer is connected by a
plug and socket, and the
socket is connected to a device
controller.
26/10/2021
PRINCIPLES OF I/O HARDWARE AND
SOFTWARE
4
Synchronous and asynchronous
I/O
26/10/2021
PRINCIPLES OF I/O HARDWARE AND
SOFTWARE
5
• Synchronous I/O – CPU execution waits while I/O proceeds .
• Asynchronous I/O – I/O proceeds concurrently with CPU execution
Communication to I/O devices
CPU and the device communicates by one of these 3 methods –
• Special Instruction I/O
• Memory Mapped I/O
• Direct Memory Access (DMA)
S P E C I A L
I N S T R U C T I O
N I / O
T H I S M E T H O D U S E S C P U
I N S T R U C T I O N S T H AT A R E
S P E C I F I C A L LY M A D E F O R
C O N T R O L L I N G I / O D E V I C E S
26/10/2021
PRINCIPLES OF I/O HARDWARE AND
SOFTWARE
6
Memory-mapped
I/O
• In Memory mapped I/O, the same address
space is shared by memory and I/O devices.
• I/O device can transfer block of data to/from
memory without going through CPU.
• OS allocates buffer in memory and informs
I/O device to use that buffer to send data to
the CPU.
• I/O device works asynchronously with the
CPU.
• Every instruction which can access memory
can be used to manipulate an I/O device.
• This method is used for high-speed I/O
devices like disks, comms interface etc.
26/10/2021
PRINCIPLES OF I/O HARDWARE AND
SOFTWARE
7
Direct Memory
Access (DMA)
• DMA means CPU grants I/O module authority
to read from or write to memory without
involvement.
• CPU is only involved at beginning and end of
the transfer and interrupted only after entire
block has been transferred.
• DMA Module controls exchange of data
between main memory and I/O device.
• It needs a special hardware called DMAC
(DMA Controller)
• The controllers are programmed with source
and destination pointers, counters to track the
number of transferred bytes, interrupts and
states for the CPU cycle.
26/10/2021
PRINCIPLES OF I/O HARDWARE AND
SOFTWARE
8
I/O
SOFTWARE
S
26/10/2021
PRINCIPLES OF I/O HARDWARE AND
SOFTWARE
9
I/O software is categorised in the
following layers –
• USER LEVEL LIBRARIES – This provides
simple interface to the user program to
perform input and output. For Eg – iostream
library in C++.
• KERNEL LEVEL MODULES – This
provides device driver to interact with the
device controller and device independent
I/O modules used by the device drivers.
• HARDWARE – This layer includes actual
hardware and controller which interacts
with the device drivers and make the
hardware work.
THE I/O SOFTWARE SHOULD BE
DESIGNED IN A WAY THAT IT
SHOULD BE INDEPENDENT OF THE
DEVICE WHERE IT SHOULD BE
POSSIBLE TO WRITE PROGRAMS
THAT CAN ACCESS ANY I/O DEVICE
WITHOUT HAVING TO SPECIFY THE
DEVICE.
26/10/2021
PRINCIPLES OF I/O HARDWARE AND
SOFTWARE
10
Device Drivers
26/10/2021
PRINCIPLES OF I/O HARDWARE AND
SOFTWARE
11
DEVICE DRIVERS ARE
THE SOFTWARE
MODULES THAT CAN BE
PLUGGED INTO AN OS TO
HANDLE A PARTICULAR
DEVICE.
OS TAKES HELP FROM
DEVICE DRIVERS TO
HANDLE ALL I/O DEVICES.
DEVICE DRIVERS
ENCAPSULATE DEVICE-
DEPENDENT CODE AND
IMPLEMENT A STANDARD
INTERFACE IN SUCH A
WAY THAT CODE
CONTAINS DEVICE–
SPECIFIC REGISTER
READS/WRITES.
DEVICE DRIVER IS
GENERALLY WRITTEN BY
THE DEVICE’S
MANUFACTURER AND
DELIVERED ALONG WITH
THE DEVICE.
NOWADAYS, DEVICE
DRIVERS ARE EASILY
AVAILABLE ON THE
INTERNET AS AN
EXECUTABLE INSTALLER.
Jobs
performe
d by a
Device
Driver
26/10/2021
PRINCIPLES OF I/O HARDWARE AND
SOFTWARE
12
To accept request from the device
independent software above to it.
Interact with the device controller
to take and give I/O and perform
required error handling.
Making sure that the request is
executed successfully
T H A N K
Y O U
26/10/2021
PRINCIPLES OF I/O HARDWARE AND
SOFTWARE
13

Principles of I/O Hardware and Software

  • 1.
    Principles of I/O Hardware, Device controllersand Device drivers OS Assig nment made by:- Karandeep Sing h Sehg al Btech(CSE)-III A50105220029
  • 2.
    Things we will cover.. ManagingI/O is one of the most important task of an OS . • Principles of I/O hardware. • Device controllers. • Device drivers 26/10/2021 PRINCIPLES OF I/O HARDWARE AND SOFTWARE 2
  • 3.
    I/O Hardware system • An I/Osystem takes an I/O request from the application and send it to the physical device, then takes back the response from physical device to the application. 26/10/2021 PRINCIPLES OF I/O HARDWARE AND SOFTWARE 3 Block Devices – Type of I/O device in which the driver communicates by sending entire blocks of data. For Eg – HDDs, USB drive. Character Devices - Type of I/O device in which the driver communicates by sending and receiving single characters. For Eg – sound cards • There are mainly two types of I/O devices
  • 4.
    Device Controllers … Devicecontrollers are basically an interface between the device and its device driver. It forms the “electrical- component” of the device. For communication with the OS, there must be a device controller for the device. It converts serial bit stream to block of bytes and perform error correction, as necessary. Any device connected to the computer is connected by a plug and socket, and the socket is connected to a device controller. 26/10/2021 PRINCIPLES OF I/O HARDWARE AND SOFTWARE 4
  • 5.
    Synchronous and asynchronous I/O 26/10/2021 PRINCIPLESOF I/O HARDWARE AND SOFTWARE 5 • Synchronous I/O – CPU execution waits while I/O proceeds . • Asynchronous I/O – I/O proceeds concurrently with CPU execution Communication to I/O devices CPU and the device communicates by one of these 3 methods – • Special Instruction I/O • Memory Mapped I/O • Direct Memory Access (DMA)
  • 6.
    S P EC I A L I N S T R U C T I O N I / O T H I S M E T H O D U S E S C P U I N S T R U C T I O N S T H AT A R E S P E C I F I C A L LY M A D E F O R C O N T R O L L I N G I / O D E V I C E S 26/10/2021 PRINCIPLES OF I/O HARDWARE AND SOFTWARE 6
  • 7.
    Memory-mapped I/O • In Memorymapped I/O, the same address space is shared by memory and I/O devices. • I/O device can transfer block of data to/from memory without going through CPU. • OS allocates buffer in memory and informs I/O device to use that buffer to send data to the CPU. • I/O device works asynchronously with the CPU. • Every instruction which can access memory can be used to manipulate an I/O device. • This method is used for high-speed I/O devices like disks, comms interface etc. 26/10/2021 PRINCIPLES OF I/O HARDWARE AND SOFTWARE 7
  • 8.
    Direct Memory Access (DMA) •DMA means CPU grants I/O module authority to read from or write to memory without involvement. • CPU is only involved at beginning and end of the transfer and interrupted only after entire block has been transferred. • DMA Module controls exchange of data between main memory and I/O device. • It needs a special hardware called DMAC (DMA Controller) • The controllers are programmed with source and destination pointers, counters to track the number of transferred bytes, interrupts and states for the CPU cycle. 26/10/2021 PRINCIPLES OF I/O HARDWARE AND SOFTWARE 8
  • 9.
    I/O SOFTWARE S 26/10/2021 PRINCIPLES OF I/OHARDWARE AND SOFTWARE 9 I/O software is categorised in the following layers – • USER LEVEL LIBRARIES – This provides simple interface to the user program to perform input and output. For Eg – iostream library in C++. • KERNEL LEVEL MODULES – This provides device driver to interact with the device controller and device independent I/O modules used by the device drivers. • HARDWARE – This layer includes actual hardware and controller which interacts with the device drivers and make the hardware work.
  • 10.
    THE I/O SOFTWARESHOULD BE DESIGNED IN A WAY THAT IT SHOULD BE INDEPENDENT OF THE DEVICE WHERE IT SHOULD BE POSSIBLE TO WRITE PROGRAMS THAT CAN ACCESS ANY I/O DEVICE WITHOUT HAVING TO SPECIFY THE DEVICE. 26/10/2021 PRINCIPLES OF I/O HARDWARE AND SOFTWARE 10
  • 11.
    Device Drivers 26/10/2021 PRINCIPLES OFI/O HARDWARE AND SOFTWARE 11 DEVICE DRIVERS ARE THE SOFTWARE MODULES THAT CAN BE PLUGGED INTO AN OS TO HANDLE A PARTICULAR DEVICE. OS TAKES HELP FROM DEVICE DRIVERS TO HANDLE ALL I/O DEVICES. DEVICE DRIVERS ENCAPSULATE DEVICE- DEPENDENT CODE AND IMPLEMENT A STANDARD INTERFACE IN SUCH A WAY THAT CODE CONTAINS DEVICE– SPECIFIC REGISTER READS/WRITES. DEVICE DRIVER IS GENERALLY WRITTEN BY THE DEVICE’S MANUFACTURER AND DELIVERED ALONG WITH THE DEVICE. NOWADAYS, DEVICE DRIVERS ARE EASILY AVAILABLE ON THE INTERNET AS AN EXECUTABLE INSTALLER.
  • 12.
    Jobs performe d by a Device Driver 26/10/2021 PRINCIPLESOF I/O HARDWARE AND SOFTWARE 12 To accept request from the device independent software above to it. Interact with the device controller to take and give I/O and perform required error handling. Making sure that the request is executed successfully
  • 13.
    T H AN K Y O U 26/10/2021 PRINCIPLES OF I/O HARDWARE AND SOFTWARE 13