Part IV I/O Systems y Chapter 13: I/O Systems p y 1 Fall 2009 - - PowerPoint PPT Presentation

part iv i o systems y
SMART_READER_LITE
LIVE PREVIEW

Part IV I/O Systems y Chapter 13: I/O Systems p y 1 Fall 2009 - - PowerPoint PPT Presentation

Part IV I/O Systems y Chapter 13: I/O Systems p y 1 Fall 2009 I/O Hardw are I/O Hardw are a typical PCI bus structure 2 How How do the How How do do the the processor he processor processor and processor and and and


slide-1
SLIDE 1

Part IV I/O Systems

Chapter 13: I/O Systems

y

p y

1

Fall 2009

slide-2
SLIDE 2

I/O Hardw are I/O Hardw are

a typical PCI bus structure

2

slide-3
SLIDE 3

How How do the he processor processor and and How How do do the the processor processor and and controller communicate? controller communicate?

Use the controller: a controller usually has a f i ( l d i d few registers (e.g., status, control, data-in and data-out). Use memory-mapped I/O. Or, a combination of both. ,

3

slide-4
SLIDE 4

Memor Memory-Mapped I/O

  • Mapped I/O

y

Each controller

I/O address Device

has a few registers that are used for

000-00F DMA controller 020-021 Interrupt controller

communicating with the CPU.

p 040-043 timer 200-20F Game controller

If these registers are part of the

200 20F Game controller 2F8-2FF Serial port (secondary) 320 32F Hard disk controller

p regular memory address space, it is

320-32F Hard-disk controller 378-37F Parallel port 3D0 3DF G hi t ll

p , called memory- mapped I/O.

3D0-3DF Graphics controller 3F0-3F7 Floppy-disk controller i i

4

pp

3F8-3FF Serial port (primary)

slide-5
SLIDE 5

Three Three Commonly

  • mmonly Seen

een Protocols Protocols Three Three Commonly Commonly Seen Seen Protocols Protocols

Pooling Interrupts Interrupts Direct Memory Access (DMA)

5

slide-6
SLIDE 6

Pollin Polling

The status register has two bits, busy and The status register has two bits, busy and command-ready. Processor Controller

wait until the busy bit is not set set the write bit in command set command-ready bit if command-ready is set, set busy do input/output transfer

6

clear the command-ready and busy

slide-7
SLIDE 7

Interru Interrupt p

device driver

CPU CPU I/O Contr I/O Controller ller

device driver initiates I/O receives interrupt ll i t t h dl initiates I/O calls interrupt handler d processes data and returns done raises interrupt resumes the

7

resumes the Interrupt task

slide-8
SLIDE 8

Direct Memor Direct Memory Access: Access: 1/2 1/2 y

For large volume data transfer, most systems use direct memory access to avoid burdening the CPU direct memory access to avoid burdening the CPU. The CPU gives the controller (1) disk address, (2) dd f t i th bl k d (3) memory address for storing the block, and (3) a byte count. Then, the CPU goes back to work.

8

slide-9
SLIDE 9

Direct Memor Direct Memory Access: Access: 2/2 2/2 y

DMA requests data transfer to memory The disk controller copies the information into the address provided by the CPU, byte-by-byte, il h b hi h i until the counter becomes 0, at which time an interrupt is generated.

9

slide-10
SLIDE 10

Application I/O Interface Application I/O Interface

10

slide-11
SLIDE 11

I/O Devices I/O Devices

Character stream: a character stream device f b b ( d ) transfers byte one by one (e.g., modem) Block: a block device transfers a block of bytes as a unit (e.g., disk) Others: clocks, memory-mapped screens and so , y pp

  • n.

Not all devices may be recognized by an OS. Not all devices may be recognized by an OS. Thus, device drivers are needed.

11

slide-12
SLIDE 12

Kernel I/O System Kernel I/O System

Build on top of hardware and device drivers, h k l ll id I/O i the kernel usually provide many I/O services: I/O scheduling (e.g., disk head scheduling) I/O Buffering (see below) Caching (see below) Caching (see below) Spooling E h dli Error handling

12

slide-13
SLIDE 13

Buffering: Buffering: 1/2 1/2 Buffering: Buffering: 1/2 1/2

A buffer is a memory area that stores data A buffer is a memory area that stores data while they are transferred between two devices

  • r between a device and an application.
  • r between a device and an application.

Major reasons of using buffers Effi i ( b l ) Efficiency (see below) Copy semantics. What if there is no buffer and a process runs so fast that overwrites its previous write? The content on the disk becomes incorrect. The use of buffers

  • vercomes this problem.

13

slide-14
SLIDE 14

Buffering: Buffering: 2/2 2/2

No buffer. The user process must wait until data transfer completes. O b ff Whil th One buffer: While the user process is running, next data transfer may begin transfer may begin Double buffer: while the user process is processing the first buffer, data transfer can be f d th d performed on the second. Multiple buffers: very efficient

14

Multiple buffers: very efficient

(figures taken from W. Stallings’ OS text)

slide-15
SLIDE 15

Caching Caching

Just like a cache memory between the faster CPU and slower physical memory, a cache (i.e., disk cache) may be used between the faster physical memory and slower I/O devices. Note that buffering and caching are different things.

controller physical memory I/O device cache cache

15

slide-16
SLIDE 16

Th E d The End

16