Input Output Patrick Happ Raul Queiroz Feitosa Parts of these - - PowerPoint PPT Presentation

input output
SMART_READER_LITE
LIVE PREVIEW

Input Output Patrick Happ Raul Queiroz Feitosa Parts of these - - PowerPoint PPT Presentation

Input Output Patrick Happ Raul Queiroz Feitosa Parts of these slides are from the support material provided by W. Stallings Objective This chapter presents concepts, structures and functions involved in I/O operation. 2 Input Output


slide-1
SLIDE 1

Input Output

Patrick Happ Raul Queiroz Feitosa

Parts of these slides are from the support material provided by W. Stallings

slide-2
SLIDE 2 Input Output 2

Objective

This chapter presents concepts, structures and functions involved in I/O operation.

slide-3
SLIDE 3 Input Output 3

Outline

 I/O Modules  I/O Techniques

Programmed I/O Interrupt driven I/O Direct Memory Access (DMA)

 I/O Channels and I/O Processors

slide-4
SLIDE 4 Input Output 4

Generic Model of I/O Module

 Wide variety of peripherals

 Delivering different amounts of

data

 At different speeds  In different formats

 Most of them slower than

CPU and RAM

 Need I/O modules as

interface

 to CPU and Memory via bus or

central switch

 to one or more peripherals

slide-5
SLIDE 5 Input Output 5

External Device Block Diagram

slide-6
SLIDE 6 Input Output 6

I/O Module Function

1.

Control & Timing

2.

CPU Communication

3.

Device Communication

4.

Data Buffering

5.

Error Detection

slide-7
SLIDE 7 Input Output 7

I/O Module Function

Control & Timing : The data transfer will typically involve the following steps:

d) I/O module gets data from device e) I/O module transfers data to CPU d) I/O module transfers data from CPU e) I/O module sends data to device a) CPU checks I/O module device status b) I/O module returns status c) If ready, CPU requests data transfer

slide-8
SLIDE 8 Input Output 8

I/O Module Function

Processor Communication : involves the following steps:

a)

Command decoding: typically word commands are sent through the bus to the I/O module.

b)

Data: exchanged between cpu and I/O module through the bus.

c)

Status reporting: because peripherals are slow the cpu must know the status of the I/O module – is it ready to receive one more data unit?

d)

Address recognition: I/O modules are accessed quite in the same way as memory locations

slide-9
SLIDE 9 Input Output 9

I/O Module Function

Device Communication

Commands, status information and data

Status/control registers Data registers Data Status Control Data Status Control External device interface logic

. . . . . .

I/O logic

Data lines Address lines Control lines

External device interface logic External device interface logic

INTERFACE TO SYSTEM BUS INTERFACE TO EXTERNAL DEVICE BLOCK DIAGRAM OF AN I/O MODULE

slide-10
SLIDE 10 Input Output 10

I/O Module Function

Data Buffering to cope with the different transfer rates between memory and peripheral devices. Error Detection and reporting to the processor

slide-11
SLIDE 11 Input Output 11

Outline

 I/O Modules  I/O Techniques

Programmed I/O Interrupt driven I/O Direct Memory Access (DMA)

 I/O Channels and I/O Processors

slide-12
SLIDE 12 Input Output 12

Input Output Techniques

I/O Technique Task

Read Status Data Transfer

  • 1. Programmed I/O

CPU CPU

  • 2. Interrupt driven I/O

I/O module CPU

  • 3. Direct Memory Access (DMA)

DMA module DMA module

slide-13
SLIDE 13 Input Output 13

Programmed I/O

busy waiting

slide-14
SLIDE 14 Input Output 14

Programmed I/O

 CPU has direct control over I/O

 Sensing status  Read/write commands  Transferring data

 CPU waits for I/O module to complete operation  Wastes CPU time  Simplest implementation

slide-15
SLIDE 15 Input Output 15

I/O Commands

CPU issues address

 Identifies module (& device if >1 per module)  Very like memory accesses with separated or common

address spaces

CPU issues command

 Control - telling module what to do

 e.g. spin up disk

 Test - check status

 e.g. power? Error?

CPU reads/writes information

 Module transfers data via buffer from/to device
slide-16
SLIDE 16 Input Output 16

I/O Mapping

Memory mapped I/O

 Devices and memory share a common address space  I/O looks just like memory read/write  No special commands for I/O

 Large selection of memory access commands available

Isolated I/O

 Separate address spaces  Need I/O or memory select lines  Special commands for I/O

 Limited set

slide-17
SLIDE 17 Input Output 17

Memory Mapped I/O

ADDRESS INSTRUCTION OPERAND COMMENT 200 Load AC “1” Load accumulator Store AC 517 Initiate keyboard read 202 Load AC 517 Get status byte Branch if Sign=0 202 Loop until ready Load AC 516 Load data byte 516 517

same instruction to access memory

slide-18
SLIDE 18 Input Output 18

ADDRESS INSTRUCTION OPERAND COMMENT 200 Load AC “1” Load accumulator Out 6 Initiate keyboard read 202 In 6 Get status byte Branch if Sign=0 202 Loop until ready In 5 Load data byte

Isolated I/O

5 6

specific instructions to access …I/O...

slide-19
SLIDE 19 Input Output 19

I/O Mapping

Status/control registers Data registers Data Status Control Data Status Control External device interface logic

. . . . . .

I/O logic RD WR memory read i/o read memory write i/o write

up → memory mapped I/O down → isolated I/O Data lines Address lines Control lines

External device interface logic External device interface logic

INTERFACE TO SYSTEM BUS INTERFACE TO EXTERNAL DEVICE

BLOCK DIAGRAM OF AN I/O MODULE

slide-20
SLIDE 20 Input Output 20

Interrupt Driven I/O

Overcomes CPU waiting No repeated CPU checking of device I/O module interrupts when ready

slide-21
SLIDE 21 Input Output 21

Interrupt Driven I/O

slide-22
SLIDE 22 Input Output 22

Simple Interrupt Processing

slide-23
SLIDE 23 Input Output 23

On Interrupt Acknowledge

N+1

1.

Processor acknowledges interrupt request, while executing instruction at location N .

2.

Processor saves current PC and register contents program.

3.

Processor loads the entry location of the interrupt- handling program.

Y+L Y N N+1 T T-M start return interrupt service routine user’s program control stack Main Memory Processor stack pointer general registers Y N+1 program counter T N+1 T-M T+1

slide-24
SLIDE 24 Input Output 24

On Interrupt Return

1.

Processor retrieves saved register contents from the stack .

2.

Processor retrieves saved PC and PSW from the stack .

Processor stack pointer general registers program counter T N+1 T-M Y+L N+1 Y+L Y N N+1 T T-M start return interrupt service routine user’s program control stack Main Memory T+1

slide-25
SLIDE 25 Input Output 25

Design Issues

1.

How do you identify the module issuing the interrupt?

2.

How do you deal with multiple interrupts?

 i.e. an interrupt handler being interrupted

slide-26
SLIDE 26 Input Output 26

Identifying Interrupting Module (1)

Different line for each module

PC Limits number of devices

Software poll

CPU asks each module in turn  Slow

slide-27
SLIDE 27 Input Output 27

Identifying Interrupting Module (2)

Daisy Chain or Hardware poll

Interrupt Acknowledge (≈ read access)

 sent down a chain, or  parallel to all devices.

Module responsible places vector on bus CPU uses vector to identify handler routine

Bus Master

Module must claim the bus before it can raise

interrupt e.g. PCI & SCSI

slide-28
SLIDE 28 Input Output 28

Direct Memory Access

Drawbacks with previous I/O strategies :

both require active CPU intervention

 Transfer rate is limited  CPU is tied up

DMA is the answer!

Additional Module (hardware) on bus DMA controller takes over from CPU for I/O

slide-29
SLIDE 29 Input Output 29

Direct Memory Access

slide-30
SLIDE 30 Input Output 30

DMA controller diagram

RD WR Status/control registers Data registers

. . . .

interrupt request request DMA memory read i/o read memory write i/o write

Data lines Address lines Control lines

DMA request DMA acknowledge External device interface logic Status/control registers Address registers Control logic DMA request DMA acknowledge External device interface logic

. .

slide-31
SLIDE 31 Input Output 31

DMA Operation

CPU tells DMA controller: CPU carries on with other work DMA controller deals with transfer DMA controller sends interrupt when finished

DMA controller command registers Read/Write Device address Starting address of memory block for data Amount of data to be transferred
slide-32
SLIDE 32 Input Output 32

DMA transfer modes

block mode cycle stealing

DMA controller takes over bus DMA controller return bus control DMA controller transfer one word DMA controller takes over bus DMA controller return bus control DMA controller transfer one word

till a whole bock is transferred till a whole bock is transferred

slide-33
SLIDE 33 Input Output 33

DMA transfer modes

In block mode as well as in cycle stealing

CPU is suspended, not interrupted

 CPU does not switch context

CPU suspended just before it accesses bus

 i.e. before an operand or data fetch or a data write

Slows down CPU but not as much as CPU doing

transfer.

slide-34
SLIDE 34 Input Output 34

DMA and Interrupt Breakpoints During an Instruction Cycle

slide-35
SLIDE 35 Input Output 35

DMA Configurations (1)

Single Bus, Detached DMA controller

(a) Single-bus, detached DMA

slide-36
SLIDE 36 Input Output 36

DMA Configurations (2)

Single Bus, Integrated DMA –I/Ocontroller Controller may support >1 device

(b) Single-bus, Integrated DMA-I/O

slide-37
SLIDE 37 Input Output 37

DMA Configurations (3)

Separate I/O Bus Bus supports all DMA enabled devices

(c) I/O Bus

slide-38
SLIDE 38 Input Output 38

Outline

 I/O Modules  I/O Techniques

Programmed I/O Interrupt driven I/O Direct Memory Access (DMA)

 I/O Channels and I/O Processors

slide-39
SLIDE 39 Input Output 39

I/O Channels and I/O Processors

 Enhanced I/O modules with a built-in programmable

processor

 if it shares the system memory  I/O channel  if it has its own memory  I/O processor

 CPU instructs I/O channel/processor to do transfer  I/O channel/processor does entire transfer and interrupts

CPU at the end.

 Improves overall speed.  e.g. 3D graphics cards.

slide-40
SLIDE 40 Input Output 40

I/O Channels and I/O Processors

Types

 Selector channel

 Controls multiple high-speed devices  And is dedicated to one of them at a time  Each (or a small set of) device is handled by a controller or I/O

module

 The IO/Channel serves in place of the CPU to control these I/O

controllers

slide-41
SLIDE 41 Input Output 41

I/O Channels and I/O Processors

Types

 Multiplexor channel

 Handle multiple devices at the same time.
slide-42
SLIDE 42

Direct Cache Access (DCA)

 Conventional DMA transfer data

between I/O and main memory.

 DCA provides a bypass over the

main memory and allows direct transfer between I/O and the lowest level cache

 Exemple XEON E5-2600/4600

Input Output 42
slide-43
SLIDE 43 Input Output 43

Outline

 I/O Modules  I/O Techniques

Programmed I/O Interrupt driven I/O Direct Memory Access (DMA)

 I/O Channels and I/O Processors

slide-44
SLIDE 44

Exercise 1

For a programmed I/O the processor is stuck in a wait loop doing status checking of an I/O device. To increase efficiency, the I/O software could be written so that the processor periodically checks the stats of the device. If the device is not ready, the process can jump to other tasks. After some timed interval, the processor comes back to check status again

a) Consider the above scheme for outputting data one character at a time to a

printer that operates at 10 characters per second (cps). What will happen if the status is scanned every 200ms?

b) Next consider a keyboard with a single character buffer. On average, characters

are entered at a rate of 10 cps. However, the time interval between two consecutive key depressions can be as short as 80 ms. At what frequency should the keyboard be scanned by the I/O programm?

Interconnection Structures 44
slide-45
SLIDE 45

Exercise 2

In this presentation one advantage and one disadvantage of memory-mapped I/O compared with isolated I/O were listed. List two more advantages and two more disadvantages.

Interconnection Structures 45
slide-46
SLIDE 46

Exercise 3

Consider a system employing interrupt-driven I/O for a particular device that transfers data at an average of 8 KB/s on a continuous basis.

a) Assume that interrupt processing takes about 100 μs (i.e., the time to

jump to the interrupt service routine (ISR), execute it, and return to the main program). Determine what fraction of processor time is consumed by this I/O device if it interrupts for every byte.

b) Now assume that the device has two 16-byte buffers and interrupts the

processor when one of the buffers is full. Naturally, interrupt processing takes longer, because the ISR must transfer 16 bytes. While executing the ISR, the processor takes about 8 μs for the transfer of each byte. Determine what fraction of processor time is consumed by this I/O device in this case.

Interconnection Structures 46
slide-47
SLIDE 47

Exercise 4

A DMA module is transferring characters to memory using cycle stealing, from a device transmitting at 9600 bps. The processor is fetching instructions at the rate of 1 million instruction per second (1 MIPS). By how much will the processor be slowed down due to the DMA activity?

Interconnection Structures 47
slide-48
SLIDE 48

Exercise 5

Consider a system in which bus cycles take 500 ns. Transfer of bus control in either direction, from processor to I/O device or vice-versa, takes 250 ns. One of the I/O devices has a data transfer rate of 50 KB/s and employs DMA. Data are transferred one byte at a time.

a) Suppose we employ DMA at a burst mode. That is, the

DMA interface gains bus mastership prior to the start of a block transfer and maintains control of the bus until the whole block is transferred. For how long would the device tie up the bus when transferring a block of 128 bytes?

b)Repeat the calculation for cycle-stealing mode.

Interconnection Structures 48
slide-49
SLIDE 49

Question of a prior G2

At t0 a disk controller receives from processor a command to transfer a 512 byte long sector to the main memory. These bytes become available in the controller’s buffer 5,000 μs after t0. The byte transfer from buffer to main memory may be executed at any time from then on. The controller may adopt three management strategies:

a) Programmed I/O: Starting at t0. + 500 μs a program is executed by the processor every 500 μs to check if the buffer is full. If the buffer is still not full, the execution time of this program is equal to 50μs. If the buffer is full, 5μs is added to this execution time for each transferred byte. The symbol t1. denotes the time when the transfer of all bytes is completed Compute the time between t0 and t1, available for the processor to execute tasks other than I/O management. b) Interruption: As soon as the buffer is full, an interrupt service routine is executed. Its execution time is the same as the program of question a) when the buffer is full. In this case the transfer is completed at t2. Compute the time between t0 and t2, available for the processor to execute tasks

  • ther than I/O management.

c) DMA: When the buffer is full the DMA controller transfers the data in block mode, one byte per μs. Assume that the time to switch bus ownership between processor and DMA controller and vice-versa are negligible. In this case the transfer is finished at t3. Compute the time between t0 and t3, available for the processor to execute tasks other than I/O management.

slide-50
SLIDE 50 Input Output 50

Text Book References

These topics are covered in

Stallings

  • chapter 8
slide-51
SLIDE 51 Input Output 51

Input Output

END