18
I/O Systems By: Kaushik Vaghani Preparared By: Kaushik Vaghani

I/O Systems - · PDF fileObjectives •Explore the structure of an operating system’s I/O subsystem •Discuss the principles of I/O hardware and its complexity •Provide details

  • Upload
    lethuy

  • View
    214

  • Download
    1

Embed Size (px)

Citation preview

Page 1: I/O Systems - · PDF fileObjectives •Explore the structure of an operating system’s I/O subsystem •Discuss the principles of I/O hardware and its complexity •Provide details

I/O Systems

By: Kaushik Vaghani

Preparared By: Kaushik Vaghani

Page 2: I/O Systems - · PDF fileObjectives •Explore the structure of an operating system’s I/O subsystem •Discuss the principles of I/O hardware and its complexity •Provide details

• I/O Hardware

• Explicit I/O Instructions vs. Memory-Mapped I/O

• Interrupts

• Programmed I/O vs. DMA

• Device Drivers

Preparared By: Kaushik Vaghani

Page 3: I/O Systems - · PDF fileObjectives •Explore the structure of an operating system’s I/O subsystem •Discuss the principles of I/O hardware and its complexity •Provide details

Objectives

• Explore the structure of an operating system’s I/O subsystem

• Discuss the principles of I/O hardware and its complexity

• Provide details of the performance aspects of I/O hardware and software

Preparared By: Kaushik Vaghani

Page 4: I/O Systems - · PDF fileObjectives •Explore the structure of an operating system’s I/O subsystem •Discuss the principles of I/O hardware and its complexity •Provide details

Overview• I/O management is a major component of operating

system design and operation– Important aspect of computer operation– I/O devices vary greatly– Various methods to control them– Performance management – New types of devices frequent

• Ports, busses, device controllers connect to various devices

• Device drivers encapsulate device details– Present uniform device-access interface to I/O subsystem

Preparared By: Kaushik Vaghani

Page 5: I/O Systems - · PDF fileObjectives •Explore the structure of an operating system’s I/O subsystem •Discuss the principles of I/O hardware and its complexity •Provide details

The Requirements of I/O• Without I/O, computers are not very useful

– But… thousands of devices, each slightly different• How can we standardize the interfaces to these devices?

– Devices unreliable: media failures and transmission errors• How can we make them reliable?

– Devices unpredictable and/or slow• How can we utilize them if we don’t know what they will do or how

they will perform?

• Some operational parameters:– Byte/Block

• Some devices provide single byte at a time (e.g. keyboard)• Others provide whole blocks (e.g. disks, tapes, etc)

– Sequential/Random• Some devices must be accessed sequentially (e.g. tape)• Others can be accessed randomly (e.g. disk, cd, etc.)

– Polling/Interrupts• Some devices require continual monitoring• Others generate interrupts when they need servicePreparared By: Kaushik Vaghani

Page 6: I/O Systems - · PDF fileObjectives •Explore the structure of an operating system’s I/O subsystem •Discuss the principles of I/O hardware and its complexity •Provide details

I/O Hardware• Incredible variety of I/O devices

– Storage

– Transmission

– Human-interface

• Common concepts – signals from I/O devices interface with computer

– Port – connection point for device

– Bus - daisy chain or shared direct access

• PCI bus common in PCs and servers, Peripheral Component Interconnect

• expansion bus connects relatively slow devices

– Controller (host adapter) – electronics that operate port, bus, device

• Sometimes integrated

• Sometimes separate circuit board (host adapter)

• Contains processor, microcode, private memory, bus controller, etc

Preparared By: Kaushik Vaghani

Page 7: I/O Systems - · PDF fileObjectives •Explore the structure of an operating system’s I/O subsystem •Discuss the principles of I/O hardware and its complexity •Provide details

A Typical PC Bus Structure

Preparared By: Kaushik Vaghani

Page 8: I/O Systems - · PDF fileObjectives •Explore the structure of an operating system’s I/O subsystem •Discuss the principles of I/O hardware and its complexity •Provide details

Modern I/O Systems

Preparared By: Kaushik Vaghani

Page 9: I/O Systems - · PDF fileObjectives •Explore the structure of an operating system’s I/O subsystem •Discuss the principles of I/O hardware and its complexity •Provide details

I/O Hardware (Cont.)

• I/O instructions control devices

• Devices usually have registers where device driver places commands, addresses, and data to write, or read data from registers after command execution

– Data-in register, data-out register, status register, control register

– Typically 1-4 bytes, or FIFO buffer

• Devices have addresses, used by

– Direct I/O instructions

– Memory-mapped I/OPreparared By: Kaushik Vaghani

Page 10: I/O Systems - · PDF fileObjectives •Explore the structure of an operating system’s I/O subsystem •Discuss the principles of I/O hardware and its complexity •Provide details

• The OS needs to know when:

– The I/O device has completed an operation

– The I/O operation has encountered an error

• One way is to Poll:

– OS periodically checks a device-specific status register

– I/O device puts completion information in status register

– Busy-wait cycle to wait for I/O from device

– Pro: simple, potentially low overhead

– Con: may waste many cycles on polling if infrequent, expensive, or unpredictable I/O operations

Notifying the OS: Polling

Preparared By: Kaushik Vaghani

Page 11: I/O Systems - · PDF fileObjectives •Explore the structure of an operating system’s I/O subsystem •Discuss the principles of I/O hardware and its complexity •Provide details

• I/O Interrupt:

– Device generates an interrupt whenever it needs service

– Pro: handles unpredictable events well

– Con: interrupts relatively high overhead

• Some devices combine both polling and interrupts

– Example: Intel E1000 Gigabit Ethernet Adapter:

• Interrupt for first incoming packet

• Poll for subsequent packets until hardware packet arrival queue is empty

Notifying the OS: Interrupts

Preparared By: Kaushik Vaghani

Page 12: I/O Systems - · PDF fileObjectives •Explore the structure of an operating system’s I/O subsystem •Discuss the principles of I/O hardware and its complexity •Provide details

Interrupt-Driven I/O Cycle

Preparared By: Kaushik Vaghani

Page 13: I/O Systems - · PDF fileObjectives •Explore the structure of an operating system’s I/O subsystem •Discuss the principles of I/O hardware and its complexity •Provide details

• Programmed I/O:

– Each byte transferred via processor in/out or load/store

– Pro: Simple hardware, easy to program

– Con: Consumes processor cycles proportional to data size

• Direct Memory Access:

– Give controller access to memory bus

– Ask it to transfer data to/from memory directly

Transferring Data To/From Controller

Preparared By: Kaushik Vaghani

Page 14: I/O Systems - · PDF fileObjectives •Explore the structure of an operating system’s I/O subsystem •Discuss the principles of I/O hardware and its complexity •Provide details

Direct Memory Access

• Used to avoid programmed I/O (one byte at a time) for large data movement

• Requires DMA controller

• Bypasses CPU to transfer data directly between I/O device and memory

Preparared By: Kaushik Vaghani

Page 15: I/O Systems - · PDF fileObjectives •Explore the structure of an operating system’s I/O subsystem •Discuss the principles of I/O hardware and its complexity •Provide details

Six Step Process to Perform DMA Transfer

Preparared By: Kaushik Vaghani

Page 16: I/O Systems - · PDF fileObjectives •Explore the structure of an operating system’s I/O subsystem •Discuss the principles of I/O hardware and its complexity •Provide details

Device Drivers

Device-specific code in the kernel that interacts directly with the device hardware

Supports a standard, internal interface

Same kernel I/O system can interact easily with different device drivers

Preparared By: Kaushik Vaghani

Page 17: I/O Systems - · PDF fileObjectives •Explore the structure of an operating system’s I/O subsystem •Discuss the principles of I/O hardware and its complexity •Provide details

Block and Character Devices

• Block devices include disk drives

– Commands include read, write, seek

– Raw I/O or file-system access

– Memory-mapped file access possible

• Character devices include keyboards, mice, serial ports

– Single character at a time

– Commands include get, put

Preparared By: Kaushik Vaghani

Page 18: I/O Systems - · PDF fileObjectives •Explore the structure of an operating system’s I/O subsystem •Discuss the principles of I/O hardware and its complexity •Provide details

Thank You

Preparared By: Kaushik Vaghani