cpr e 308 input/output recall: os must abstract out all the details of specific i/o devices today...

13
Cpr E 308 Input/Output • Recall: OS must abstract out all the details of specific I/O devices • Today – Block and Character Devices – Hardware Issues – Programmed I/O, DMA, etc – Interrupt Handlers, Device Drivers

Upload: rebecca-miller

Post on 29-Dec-2015

220 views

Category:

Documents


0 download

TRANSCRIPT

Cpr E 308

Input/Output

• Recall: OS must abstract out all the details of specific I/O devices

• Today– Block and Character Devices– Hardware Issues – Programmed I/O, DMA, etc– Interrupt Handlers, Device Drivers

Cpr E 308

Input/Output Devices

• Disk, CD-ROM

• Printer

• Terminal

• Keyboard

• Mouse

Block Devices

Character Devices

Cpr E 308

Data Rates

Cpr E 308

Hardware Issues

• Device Controller– Hardware that comes with the device and interfaces

with the computer

• Memory mapped I/O– I/O happens by writing into locations in the process’s

address space

– Ex: Pentium, addresses 640K to 1M are reserved for device data buffers

Cpr E 308

Simple I/O Architecture

Bus

ControllerController

Memory

Controller

Disk

Processor

Copyright © 2002 Thomas W. Doeppner. All rights reserved.

Cpr E 308

I/O Transfer

• Programmed I/O– Ex: Terminal– Read/write into the device data registers one byte (word) at a time– Interrupt happens when each byte has been handled

• Direct Memory Access (DMA)– Ex: Disk– CPU notifies the location and size of the memory buffer, and the

I/O device address– Data transferred without CPU involvement– Separate DMA controller involved– Interrupt occurs when all data is handled

• Sometimes, DMA might be slower than programmed I/O

Cpr E 308

I/O Software Layers

User Level I/O Software (printf, etc)

Device-independent OS Software

Device Drivers

Interrupt Handlers

Hardware

Cpr E 308

Interrupt Handlers• Interrupt handlers are best hidden

– have driver starting an I/O operation block until interrupt notifies of completion

• Interrupt procedure does its task– then unblocks driver that started it

• Steps must be performed in software after interrupt completed

1. Save regs not already saved by interrupt hardware2. Set up context for interrupt service procedure

Cpr E 308

Interrupt Handlers (2)

3. Set up stack for interrupt service procedure

4. Ack interrupt controller, reenable interrupts

5. Copy registers from where saved

6. Run service procedure

7. Set up MMU context for process to run next

8. Load new process' registers

9. Start running the new process

Cpr E 308

Device Driver

• Talks to the device controller

• Knows all details about the device, its registers, etc

• Presents a device independent interface to the higher layers of the OS

• Usually supplied by manufacturer (need a different one for each OS)

Cpr E 308

Device Drivers

• Communications between drivers and device controllers goes over the bus

Cpr E 308

Device driver interfaces

• Block interface– Read and write blocks, seek

• Stream interface (for character devices)– Get/put next element

– Can be augmented by undoing previous operation

• Memory-like interface

Cpr E 308

I/O Processors: Channels

Memory

Processor

ControllerChannel

ControllerChannel

ControllerChannel

Copyright © 2002 Thomas W. Doeppner. All rights reserved.