I/O SYSTEMS Sunu Wibirama Are you surely IT class member? Then - - PowerPoint PPT Presentation

i o systems
SMART_READER_LITE
LIVE PREVIEW

I/O SYSTEMS Sunu Wibirama Are you surely IT class member? Then - - PowerPoint PPT Presentation

I/O SYSTEMS Sunu Wibirama Are you surely IT class member? Then you should know these pictures... Introduction Main job of computer : I/O and processing (the latter is rarely happened) Browsing: read and enter information, not


slide-1
SLIDE 1

I/O SYSTEMS

Sunu Wibirama

slide-2
SLIDE 2

Are you surely IT class member?

Then you should know these pictures...

slide-3
SLIDE 3
slide-4
SLIDE 4

13.

Introduction

Main job of computer : I/O and processing (the latter is rarely happened)

Browsing: read and enter information, not compute an answer

OS: manage, control I/O devices and operations

We will explore:

 I/O Hardware  Application I/O Interface  Kernel I/O Subsystem  Transforming I/O Requests to Hardware Operations  STREAMS  Performance

At the end of this presentation, we will talk about final assignment and final test (UAS)

slide-5
SLIDE 5

13.

I/O Hardware

Major concern of OS designer is: I/O support

Incredible variety of I/O devices: mouse, hard disk, cd-rom, usb, etc.

Common concepts of I/O hardware elements:

 Port / connection point (ex.: serial port, parallel port)  Bus: wires with spesific protocol  Controller (host adapter) - Serial-port controller v.s. SCSI controller

Details are encapsulated in device-driver module in OS kernel

Device drivers: uniform I/O instructions to control I/O devices

Controller has one or more registers for data and control signals

Devices have addresses, used by

 Direct I/O instructions using bus: send instructions to an I/O port

address

 Memory-mapped I/O: device-control registers are mapped into the

address space of the processor

slide-6
SLIDE 6

13.

A Typical PC Bus Structure

slide-7
SLIDE 7

13.

Device I/O Port Locations on PCs (partial)

slide-8
SLIDE 8

13.

I/O Port’s Register

Data-in register: read by the host to get input

Data-out register: written by the host to send output

Status register: contain status bits that can be read by the host

Control register: can be written by the host to start command or to change the mode of the device. Example:

 Full-duplex or half-duplex mode;  Duplex: communicate (send and receive message). Half-duplex: only

  • ne activity at one time. Full-duplex: can either send or receive

information at the same time.

slide-9
SLIDE 9

13.

Polling

Explain I/O host and I/O controller communication

Controller:

 Status register: 1 - busy and 0 - clear

Host:

 Command register: command-ready bit

Handshaking step (repeated for each byte):

 Host repeatedly read busy bit until that bit becomes clear (busy waiting or polling)  Host sets the write bit in the command register and writes a byte into the data-out

register

 Host sets command-ready bit  Controller notices that command-ready bit is set, it sets the busy bit  Controller reads the command register, sees the write command. It reads data-out

register to get the byte and does the I/O to the device

 Controller clears command-ready bit, clears error bit in the status register to

indicate I/O succeeded, clears the busy bit to indicate that I/O operation is finished

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

More efficient, if the controller notify the CPU when itʼs ready to operate: interrupts

slide-10
SLIDE 10

13.

Interrupt-Driven I/O Cycle

slide-11
SLIDE 11

13.

Interrupts

Interrupts-request line: receiving interrupts from I/O contoller

Nonmaskable interrupt: reserved for events such as unrecoverable memory errors.

Maskable to ignore or delay some interrupts

Interrupt mechanism accepts an address - a number that selects a specific interrupt-handling routine from a small set (the number is called interrupt-vector)

Interrupt-vector contains the memory address of specialized interrupt-handlers.

Interrupt mechanism uses interrupt priority level (low or high priority interrupt)

Interrupt mechanism also used for exceptions (such as: dividing by zero, accessing protected or nonexistent memory address, attempting to execute a privileged instruction from user mode).

slide-12
SLIDE 12

13.

Direct Memory Access

Large data transfer: disk drive

Used to avoid programmed I/O for large data movement (= watch status bits and to feed data into a controller register one byte at a time)

Requires DMA controller

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

slide-13
SLIDE 13

13.

Six Step Process to Perform DMA Transfer

slide-14
SLIDE 14

13.

Application I/O Interface

Explain interface and techniques of OS to treat I/O devices in standard way (such as open a file on a disk without knowing what kind of disk it is).

I/O system calls encapsulate device behaviors in generic classes

Device-driver layer hides differences among I/O controllers from kernel

Devices vary in many dimensions

 Character-stream or block  Sequential or random-access  Sharable or dedicated  Speed of operation  read-write, read only, or write only

slide-15
SLIDE 15

13.

A Kernel I/O Structure

uniformity

think the structure as organization structure: head of organization doesn’t need to know the detail

slide-16
SLIDE 16

13.

Characteristics of I/O Devices

slide-17
SLIDE 17

13.

Kernel I/O Subsystem

Kernel provides many services to I/O, such as:

 scheduling  buffering  caching  spooling  device reservation  error handling

These are provided by I/O subsystem, build on hardware and device-driver infrastructure

slide-18
SLIDE 18

13.

Kernel I/O Subsystem

Scheduling

 Meaning: to determine a good order to execute I/O requests  Can improve overall system performance  Some I/O request ordering via per-device queue  Some OSs try fairness

Buffering - store data in memory while transferring between devices

 To deal with device speed mismatch (modem v.s. storage)  To deal with device transfer size mismatch (data re-assemble)  To maintain “copy semantics” (data reliability when write() system call is

executed).

slide-19
SLIDE 19

13.

Sun Enterprise 6000 Device-Transfer Rates

slide-20
SLIDE 20

13.

Kernel I/O Subsystem

Caching - fast memory holding copy of data (do you remember the function of proxy

server in networking? - you need to press CTRL+F5 to renew the cache)  Always just a copy (not the only existing item - as buffer does)  Key to performance

Spooling - hold output for a device

 If device can serve only one request at a time  i.e., Printing - no interleave allowed

Device reservation - provides exclusive access to a device

 System calls for allocation and deallocation  Watch out for deadlock

slide-21
SLIDE 21

13.

Error Handling

OS can recover from disk read, device unavailable or defective, transient write failures

Most return an error number or code when I/O request fails

 Unix : errno 2 - no such file or directory

System error logs hold problem reports

slide-22
SLIDE 22

13.

I/O Protection

User process may accidentally or purposefully attempt to disrupt normal operation via illegal I/O instructions

 All I/O instructions defined to

be privileged: I/O must be performed via OSʼ system calls

 Memory-mapped and I/O

port memory locations must be protected too (ex.: graphic games and video editing should access the memory

  • directly. OS should protects a

block of memory for graphic processing at one time)

slide-23
SLIDE 23

13.

Kernel Data Structures

Kernel keeps state info for I/O components, including open file tables, network connections, character device state

Many, many complex data structures to track buffers, memory allocation, “dirty” blocks

Unix uses object-oriented methods to encapsulate “differences” (for example: read() operation, the semantics is different for each I/O devices)

Windows uses message passing to implement I/O

 I/O request is converted into a message through the kernel to the

I/O manager and then to device driver, each of which may change the message contents. For output, the message contains data to be written. For input, the message contains buffer to receive data.

slide-24
SLIDE 24

13.

I/O Requests to Hardware Operations

Consider reading a file from disk for a process:

 Determine device holding file  Translate name to device representation  Physically read data from disk into buffer  Make data available to requesting process  Return control to process

slide-25
SLIDE 25

Next week: Security

slide-26
SLIDE 26

Final Assignment