From Device Classes to Devices

Download Report

Transcript From Device Classes to Devices

INPUT/OUTPUT
FROM DEVICE
CLASSES TO
DEVICES
THEMES
• Wild disparity among i/o devices
• Fast CPU slow (even among the fastest) i/o devices
• What is the CPU to do when i/o is happening?
• How does CPU know when device is ready?
• How is data transferred to/from i/o device to RAM
• How to classify i/o devices in all their splendor?
COMMON
I/O DEVICES
Notice the
difference in data
rates.
Puts pressure on
software to deal
with data rates that
vary by many orders
of magnitude.
HIERARCHICAL VIEW OF I/O
SYSTEM
NOTICE THE STRUCTURE
• Driver: often a standard interface (SATA, SCSI, USB...)
to controller. Available to the o/s
• Device Controller/Adapter: Electronic Part
• Controls mechanical device
• For disk: convert serial bit stream into a block of bytes
• For monitor: reads bytes from memory, generates signals to modify
polarization of appropriate pixels
• Without monitor controller: O/S developer would have to explicitly
program the electric fields of all pixels
THREE BASIC FUNCTIONS
1.
Presents logical/abstract view of communication and
storage devices by hiding details of physical devices
2.
Allows efficient use of communication and storage
devices
3.
Supports convenient sharing of communication and
storage devices
WHERE I/O FITS
• Layer of software that resides between
• low-level hardware of individual devices
• and the higher level o/s subsystems (like the file system or virtual
memory) that use the devices
• I/O subsystem never communicates with devices directly
but only through device controllers
TWO LAYERS OF I/O SOFTWARE
• Device Drivers
• Embody specific knowledge of devices they access
• Supplied by the manufacturer of the device
• New driver must be installed whenever a new device is added
• Device Independent Software
• Drivers can be abstracted into groups controlled by common software
• Block-oriented device management
• Stream (or character)-oriented management
• Network communications software
BLOCK-DEVICE INTERFACE
• Best Example: Disk
• Storage devices that organize data into contiguous blocks
of fixed size
• Support direct access to blocks through block number or
address
BLOCK DEVICE OPERATIONS
• Open: device is operational and prepares it for access
• Read: copies the contents of a specified block into a specified area of
RAM
• Write: overwrites a specified block with data copied from a region of
RAM
• Close: releases the device or decrements the number of processes
sharing it.
• File-System uses the block-device interface to access the disk
• Virtual Memory accesses the block-device interface during a page fault
THE STREAM DEVICE INTERFACE
• Best Example: Keyboard/Monitor
• Sometimes called “character” device.
• Controls devices that produce/consume streams of
characters of arbitrary length
• Characters within a stream may not be addressed directly
• Stream devices must be used exclusively
STREAM DEVICE OPERATIONS
• get: returns next character in stream
• put: appends character to output stream
• open/close: reserve/release a device
• Stream devices vary greatly (printer vs. a graphics monitor)
so the interface needs an io_control that accepts different
parameters to express device-specific functions
NETWORK COMMUNICATION
INTERFACE
• Best Example: Network Adapter
• Makes it possible for a computer to communicate with
other computers and devices
NETWORK INTERFACE
OPERATIONS
• Socket: High-level abstraction for connection between two
computers
• Two devices that wish to communicate
• create a socket
• bind to each others’ network address
• Use TCP/IP to handle low-level read/write
• Like so many other things
• invented by DOD in sixties and seventies
• DARPA,Vinton Cerf, Robert Kahn
A Stanford Research Institute
packet radio van, site of the first
three-way internetworked
transmission
DIAGRAM OF FIRST
INTERNETWORKED
COMMUNICATION
A FEW DEVICE CLASSES:
TERMINALS (COMBINATION OF
MONITOR, KEYBOARD, MOUSE)
• Monitor: character-based or graphic
• Keyboard
• Pointing Devices (mouse, invented in the early 60’s)
MONITORS
a: character at a time displayed on screen
at cursor position or interpreted as a
control character
In Action
Here it is
b: video ram memory holds copy of
entire image. Each pixel is a separate cell
in video ram. Since cells are randomly
accessible, the image may be changed by
modifying corresponding cells
KEYBOARDS
• QWERTY keyboards date to the 2nd half of the 19th century
• From POV of i/o system, keyboards are similar to
character-based monitors
• Pressing a key causes a character to be appended to a stream of
characters in controller input buffer
• control characters operate on the buffer
• erase it
• delete the last character
• delete the last word (final project)
POINTER DEVICES (INVENTED IN
THE EARLY SIXTIES)
• Movement is detected by the hardware and translated into a byte
stream
• I/O software retrieves byte stream from input buffer and makes it
available to application software—which determines the
corresponding cursor movement or action resulting from button
pressing
OTHERS
• Printers
• Impact: line, daisy wheel, dot-matrix
• Non-impact: thermal, ink-jet, laser
• Could be character or graphics devices
• Input stream is device specific and hidden inside device drivers
DISKS
• Organized into concentric rings or tracks
• Tracks subdivided into sectors
• Each sector is a unit of information that can be read with a
single operation
• read/write head positioned over the track containing the
desired sector
DISK SECTOR NUMBERING SCHEMES
a. (track,sector)
b. Sequential numbering
d. Double Sided
c. Track Skew
Suppose reading 17 and 18
requires going from track 0 to
track 1. If 18 were adjacent to
17, will have passed by the time
the r/w head gets to track 2. To
fix the problem, offset the
sequential numbering by one or
more sectors. Here is track
skew of 1
DISK CYLINDERS