0% found this document useful (0 votes)
60 views

I/O Systems: Source: Operating System Concepts by Silberschatz, Galvin and Gagne

The document discusses computer input/output (I/O) systems. It covers I/O hardware components like buses, controllers and devices. It describes two methods of data transfer between devices and memory: programmed I/O and direct memory access. It also discusses the kernel I/O subsystem, which provides services like scheduling, buffering, error handling and translation. The I/O system calls interface provides applications access to a wide range of functionality, while streams allow full-duplex connections between devices and processes. I/O operations consume significant CPU time due to the layered software architecture between physical devices and applications.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views

I/O Systems: Source: Operating System Concepts by Silberschatz, Galvin and Gagne

The document discusses computer input/output (I/O) systems. It covers I/O hardware components like buses, controllers and devices. It describes two methods of data transfer between devices and memory: programmed I/O and direct memory access. It also discusses the kernel I/O subsystem, which provides services like scheduling, buffering, error handling and translation. The I/O system calls interface provides applications access to a wide range of functionality, while streams allow full-duplex connections between devices and processes. I/O operations consume significant CPU time due to the layered software architecture between physical devices and applications.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 29

I/O Systems

Source: Operating System Concepts by Silberschatz, Galvin and Gagne.

CSC 4103: Operating System

13.1

B.B. Karki, LSU

Overview
Computer does I/O and processing IO can be a major job (browse web or edit a file) OS manages I/O devices and operations Two conflicting trends: A wide variety of I/O devices Standardization of software and hardware interfaces. I/O Hardware Application I/O Interface Kernel I/O Subsystem Transforming I/O Requests to Hardware Operations Streams Performance

CSC 4103: Operating System

13.2

B.B. Karki, LSU

I/O Hardware

A variety of I/O devices Common concepts Port - a connection point Bus (daisy chain) PCI bus Controller (Simple controller or a host adapter) I/O transfer mechanism Direct I/O instructions Memory-mapped I/O

CSC 4103: Operating System

13.3

B.B. Karki, LSU

A Typical PC Bus Structure

CSC 4103: Operating System

13.4

B.B. Karki, LSU

I/O Port Registers

Status register Read to indicate command completion, data availability, device error. Control register Write to start a command or to change a device mode. Data-in register Read to get input Data-out register Write to send the output

CSC 4103: Operating System

13.5

B.B. Karki, LSU

Polling

Protocol for interaction between the host and a controller. Simple handshaking notion using bits. Determines state of device busy command-ready error

Busy-waiting or polling loop Reading the status register over and over until the busy bit becomes clear.

CSC 4103: Operating System

13.6

B.B. Karki, LSU

Interrupts
CPU Interrupt request line triggered by I/O device Interrupt handler receives interrupts Two interrupt request lines: Nonmaskable for events such as unrecoverable memory errors Maskable to ignore or delay some interrupts Interrupt mechanism: Interrupt vector to dispatch interrupt to correct handler Based on priority Interrupt mechanism also used for Exceptions (dividing by zero, attempting to execute a privileged instruction from user mode) Virtual-memory paging (page fault) System calls ( executes a trap) Managing flow control (e.g., interrupting a disk read) Timers
13.7

CSC 4103: Operating System

B.B. Karki, LSU

Interrupt-Driven I/O Cycle

CSC 4103: Operating System

13.8

B.B. Karki, LSU

Intel Pentium Processor Event-Vector Table

CSC 4103: Operating System

13.9

B.B. Karki, LSU

Direct Memory Access

Programmed I/O (PIO) Watch status bits and feed data into a controller register one byte at a time PIO is not useful for large data movement Direct-memory-access (DMA) controller A special purpose processor to bypass CPU to transfer data directly between I/O device and memory CPU writes the address of a DMA command-block into DMA controller which then operates the memory bus directly. Handshaking between the DMA and device controllers occurs using DMA-request and DMA-acknowledge wires. Cycle stealing - preventing CUP from accessing main memory.
13.10

CSC 4103: Operating System

B.B. Karki, LSU

DMA Transfer

CSC 4103: Operating System

13.11

B.B. Karki, LSU

Application I/O Interface


I/O system calls encapsulate device behaviors in generic

classes.
Device-driver layer hides differences among I/O controllers

from kernel.
To interface the hardware to OS.

Devices vary in many dimensions Character-stream or block Sequential or random-access Synchronous or asynchronous Sharable or dedicated Speed of operation read-write, read only, or write only.

CSC 4103: Operating System

13.12

B.B. Karki, LSU

A Kernel I/O Structure

How the I/O-related portions of the kernel are structured in the software layers.
CSC 4103: Operating System 13.13 B.B. Karki, LSU

Characteristics of I/O Devices

CSC 4103: Operating System

13.14

B.B. Karki, LSU

Block and Character Devices

Block-device interface: transfer blocks of data Disk device Commands: read, write, seek Raw I/O or file-system access Memory-mapped file access possible. Character-stream interface: transfer byte by byte Keyboards, mice, serial ports Commands: get, put Libraries layered on top allow line-at-a-time access.

CSC 4103: Operating System

13.15

B.B. Karki, LSU

Network Devices

Network I/O interface: network socket interface Unix and Windows NT Separates network protocol from network operation Includes select functionality to manage a set of sockets Approaches vary widely (pipes, FIFOs, streams,

message queues, mailboxes.)

CSC 4103: Operating System

13.16

B.B. Karki, LSU

Clocks and Timers

Three basic functions: Provide current time Provide elapsed time Set a timer to trigger an operation at a specified time. Hardware a programmable interval timer: Used for timings, periodic interrupts (e.g., CPU scheduler).

CSC 4103: Operating System

13.17

B.B. Karki, LSU

Blocking and Nonblocking I/O

Blocking - process suspended until I/O completed Easy to use and understand Insufficient for some needs Nonblocking - I/O call returns as much as available User interface, data copy (buffered I/O) Implemented via multi-threading Returns quickly with count of bytes read or written Asynchronous - process runs while I/O executes Difficult to use I/O subsystem signals process when I/O completed

CSC 4103: Operating System

13.18

B.B. Karki, LSU

Kernel I/O Subsystem

Kernels provide many services related to I/O Built on the hardware and device driver infrastructure. Scheduling Some I/O request ordering via per-device queue Some OSs try fairness Buffering - store data in memory while transferring

between devices
To cope with device speed mismatch To cope with device transfer size mismatch To maintain copy semantics.

CSC 4103: Operating System

13.19

B.B. Karki, LSU

Sun Enterprise 6000 Device-Transfer Rates

CSC 4103: Operating System

13.20

B.B. Karki, LSU

More I/O Services


Caching - fast memory holding copy of data Always just a copy Key to performance Spooling - hold output for a device If device can serve only one request at a time, e.g., printing Device reservation - provides exclusive access to a device System calls for allocation and deallocation Watch out for deadlock Error handling OS can recover from disk read, device unavailable, transient write failures Most return an error number or code when I/O request fails System error logs hold problem reports.

CSC 4103: Operating System

13.21

B.B. Karki, LSU

Kernel Data Structures

Kernel keeps state info for I/O components, including

open file tables, network connections, character device state.


Many complex data structures to track buffers, memory

allocation, dirty blocks.


Some use object-oriented methods and message passing

to implement I/O.

CSC 4103: Operating System

13.22

B.B. Karki, LSU

UNIX I/O Kernel Structure

CSC 4103: Operating System

13.23

B.B. Karki, LSU

I/O Requests to Hardware Operations

Consider reading a file from

disk for a process:


Determine device holding file Translate name to device

representation Physically read data from disk into buffer Make data available to requesting process Return control to process.

The life cycle of an I/O request


CSC 4103: Operating System 13.24 B.B. Karki, LSU

STREAMS
STREAM a full-duplex

communication channel between a user process and a device.


A STREAM consists of: STREAM head interfaces with the user process driver end interfaces with the device zero or more STREAM modules between them. Each module contains a

read queue and a write queue.


Message passing is used to

communicate between queues.


CSC 4103: Operating System 13.25 B.B. Karki, LSU

Performance
I/O a major factor in

system performance:
Demands CPU to

execute device driver, kernel I/O code, process scheduling Context switches due to interrupts Data copying Network traffic especially stressful

Intercomputer communications
CSC 4103: Operating System 13.26 B.B. Karki, LSU

Improving Performance

Reduce number of context switches Reduce data copying Reduce interrupts by using large transfers, smart controllers,

polling
Use DMA Move processing primitives into hardware (device controllers) Balance CPU, memory, bus, and I/O performance for highest

throughput.

CSC 4103: Operating System

13.27

B.B. Karki, LSU

Device-Functionality Progression

CSC 4103: Operating System

13.28

B.B. Karki, LSU

Summary
Basic I/O hardware elements are buses, device controllers, and devices Two ways of data transfer between devices and memory Programmed I/O DMA controller System-call interface provides a wide range of functionality Kernels I/O subsystem provides services such as I/O scheduling,

buffering, spooling, error handling, device reservation, and translation.


STREAMS allows a full-duplex connection between a device driver and a

user-level process.
I/O system calls consume CPU time a lot because of the many layers of

software between a physical device and the application.


13.29

CSC 4103: Operating System

B.B. Karki, LSU

You might also like