Docsity

Class Notes for Input and Output I - Operating Systems Design | CS 423, Study notes of Operating Systems

Partial preview of the text

Download Class Notes for Input and Output I - Operating Systems Design | CS 423 and more Study notes Operating Systems in PDF only on Docsity!

Input/Output

I

cs

Klara

Nahrstedt/Sam

King

10/16/

AdministrativeAdministrative

-^

MP

is

out

Page

Replacement

  • FIFO

and

Second

Chance

Start

early

D

dli

N

b^

5 2007 (M

d

8

)

Deadline

N

ovember

5

,^2007

(M

onday,

8

am)

-^

Re

‐grading

of

HW

and

Midterm

is

still

going

on

for online

‐Internet students

for

online

Internet

students

-^

On

‐campus

students

should

pick

up

their

midterms

from

Kenton’s

office

-^

Online

‐Internet

students

should

have

received

scanned

HW

and

Midterm

on

Friday

10/16/

DevicesDevices

•^

DevicesDevices^ –

Storage

devices

(disk,

tapes)

Transmission devices (network card modem)

Transmission

devices

(network

card

,^

modem)

Human

interface

devices

(screen,

keyboard,

mouse)mouse)

Specialized

device

(joystick)

10/16/

Device

‐Computer/Device

‐Device

Communication

•^

Physically: via signals over a cable or throughPhysically:

via

signals

over

a

cable

or

through

air

-^

Logically: via a connection point

port (e G

•^

Logically:

via

a

connection

point

port

(e

.G.,

Serial

port)

M l i l

d

i^

d

i^

b

•^

M

ultiple

d

evices

are

connected

via

a

b

us

A

common

set

of

wires

and

a

rigidly

defined

l h

ifi

f^

h

protocol

that

specifies

a

set

of

messages

that

can

be

sent

on

the

wires

10/16/

I/O PortsI/O

Ports

•^

4 registers

status control data

‐in data

‐out

registers

status

,^

control

,^

data

in

,^

data

out

Status

‐

states

whether

the

current

command

is

completed byte is available device has an errorcompleted

,^ byte

is

available

,^ device

has

an

error

,

etc

Control

‐

host determines to start a command or

Control

host

determines

to

start

a

command

or

change

the

mode

of

a

device

Data

‐in

‐

host

reads

to

g

et

input g^

p

Data

‐out

‐

host

writes

to

send

output

•^

Size of registers

1 to 4 bytes

10/16/

Size

of

registers

to

bytes

Interrupt

‐Driven

I/O

(H

ll

i^

f^

(H

ost

‐controller

i

nterface)

-^

CPU hardware has the interrupt report line thatCPU

hardware

has

the

interrupt

report

line

that

the

CPU

senses

after

executing

every

instruction

device raises an interruptdevice

raises

an

interrupt

CPU

catches

the

interrupt

and

saves

the

state

(e.g.,

Instruction

pointer)

CPU

dispatches

the

interrupt

handler

interrupt

handler

determines

cause,

services

the

device

and

clears

the

interrupt

-^

Why

interrupts?

10/16/

Direct Memory Access (DMA)Direct

Memory

Access

(DMA)

•^

Programmed I/O (PIO)Programmed

I/O

(PIO)

use

CPU

to

watch

status

bits

and

feed

data

into

a

controller register 1 byte at a time

‐

EXPENSIVE for

controller

register

1

byte

at

a

time

EXPENSIVE

for

large

transfers

•^

Direct memory access (DMA)Direct

memory

access

(DMA)

use

a

special

purpose

processor,

called

a

DMA

controllercontroller

10/16/

Direct Memory Access (DMA)Direct

Memory

Access

(DMA)

DMA

controller

feeds

the

characters

to

disk

one

at

the

time,

without

CPU

being

bothered.

DMA

is^ actually

the

programmed

IO,

only

with

DMA

controller

doing

the

work.

What are the issues with DMA?

10/16/

What

are

the

issues

with

DMA?

Memory

‐Mapped I/O (1)

Memory

Mapped

I/O

•^

(a)

Separate

I/O

and

memory

space

(b) M

d I/O

•^

(b)

M

emory

‐mapped

I/O

•^

(^

c)

Hybrid

10/16/

Memory

‐Mapped I/O (2)

Memory

Mapped

I/O

(a)

A

single

‐bus

architecture

(b)

A

dual

‐bus

memory

architecture

10/16/

Programmed I/OProgrammed

I/O

-^

Three

ways

to

p

erform

I/O

y^

p^

/

-^

Interrupt

‐driven

IO

-^

IO

using

DMA

programmed IO

-^

programmed

IO

.

-^

Every

IO

operation

is

programmed

and

controlled.

-^

Example:

printing

a^

file

from

user

program

to

the

printer

means

that

data

is first copied to the kernel then the OS enters a tight loop outputting theis^

first

copied

to

the

kernel

,^ then

the

OS

enters

a^

tight

loop

outputting

the

characters

one

at

a^

time.

-^

Essential

aspect

of

programmed

IO

is

that

the

CPU

continuously

polls

the

device

to

see

if

it

is

ready

to

accept

another

character.

It

uses

p

olling

(or

y^

p^

p^

g^ (

busy

waiting)

behavior.

-^

Programmed

IO

is

simple

but

required

CPU

full

time

until

all

the

IO

is

done.

10/16/

Host

Controller Interface: Polling

Host

Controller

Interface:

Polling

•^

Consider a producer

‐consumer relation

Consider

a

producer

consumer

relation

between

controller

and

host

•^

Controller indicates through

busy bit

(status

•^

Controller

indicates

through

busy

bit

(status

bit)

if

it

is

busy

to

work

or

not

H

i^

l^

i^

i h

i^

d

d

bi

•^

H

ost

signals

i

ts

wishes

via

command

‐ready

bi

t

(command

register)

•^

Polling

behavior

10/16/

TradeoffsTradeoffs

•^

Interrupt

‐driven

IO:

Interrupt

driven

IO:

Pro:

save

CPU

time

for

busy

polling

Con:

triggering

interrupt

takes

time,

too.

gg

g^

p

,

•^

Programmed

I/O

Pro: require no interrupt or DMA supportPro:

require

no

interrupt

or

DMA

support

Con:

waste

CPU

time

•^

I/O using DMA:I/O

using

DMA:

Pro:

relieve

CPU

from

I/O

operation

Con: DMA is slower than CPU

10/16/

Con:

DMA

is

slower

than

CPU

Device ClassificationDevice

Classification

•^

Character

‐stream or block devices

Character

stream

or

block

devices

•^

Sequential

or

random

access

devices

S

h

h

d

i

•^

S

ynchronous

or

asynchronous

d

evices

•^

Sharable

or

dedicated

devices

•^

Speed

of

operation

•^

WO RO RW devicesWO

,^

RO

,^

RW

devices

10/16/