Silberschatz and Galvin Chapter 12

Similar documents
Module 12: I/O Systems

Chapter 13: I/O Systems

Module 12: I/O Systems

Chapter 13: I/O Systems

Chapter 13: I/O Systems. Chapter 13: I/O Systems. Objectives. I/O Hardware. A Typical PC Bus Structure. Device I/O Port Locations on PCs (partial)

Chapter 13: I/O Systems

Chapter 12: I/O Systems

Chapter 13: I/O Systems

Chapter 12: I/O Systems. Operating System Concepts Essentials 8 th Edition

Chapter 13: I/O Systems

Device-Functionality Progression

Chapter 12: I/O Systems. I/O Hardware

The control of I/O devices is a major concern for OS designers

by I.-C. Lin, Dept. CS, NCTU. Textbook: Operating System Concepts 8ed CHAPTER 13: I/O SYSTEMS

Chapter 13: I/O Systems. Operating System Concepts 9 th Edition

Lecture 13 Input/Output (I/O) Systems (chapter 13)

I/O Systems. 04/16/2007 CSCI 315 Operating Systems Design 1

I/O Systems. Amir H. Payberah. Amirkabir University of Technology (Tehran Polytechnic)

Chapter 13: I/O Systems

Chapter 13: I/O Systems

Chapter 13: I/O Systems

Input/Output Systems

Chapter 13: I/O Systems

操作系统概念 13. I/O Systems

Ref: Chap 12. Secondary Storage and I/O Systems. Applied Operating System Concepts 12.1

I/O AND DEVICE HANDLING Operating Systems Design Euiseong Seo

Che-Wei Chang Department of Computer Science and Information Engineering, Chang Gung University

CSE 4/521 Introduction to Operating Systems. Lecture 24 I/O Systems (Overview, Application I/O Interface, Kernel I/O Subsystem) Summer 2018

Module 11: I/O Systems

Lecture 15: I/O Devices & Drivers

Operating System: Chap13 I/O Systems. National Tsing-Hua University 2016, Fall Semester

I/O SYSTEMS. Sunu Wibirama

CSC Operating Systems Spring Lecture - XIX Storage and I/O - II. Tevfik Koşar. Louisiana State University.

RAID Structure. RAID Levels. RAID (cont) RAID (0 + 1) and (1 + 0) Tevfik Koşar. Hierarchical Storage Management (HSM)

Operating Systems 2010/2011

COT 4600 Operating Systems Fall Dan C. Marinescu Office: HEC 439 B Office hours: Tu-Th 3:00-4:00 PM

NWI-IBC019: Operating systems

CS420: Operating Systems. Kernel I/O Subsystem

Outline. Operating Systems: Devices and I/O p. 1/18

[08] IO SUBSYSTEM 1. 1

Input/Output Systems

I/O Systems. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

Operating Systems 2010/2011

I/O Handling. ECE 650 Systems Programming & Engineering Duke University, Spring Based on Operating Systems Concepts, Silberschatz Chapter 13

CS330: Operating System and Lab. (Spring 2006) I/O Systems

CHAPTER 12 AND 13 - MASS-STORAGE STRUCTURE & I/O- SYSTEMS

CS370 Operating Systems

Comp 204: Computer Systems and Their Implementation. Lecture 18: Devices

Devices. Today. Comp 104: Operating Systems Concepts. Operating System An Abstract View 05/01/2017. Devices. Devices

I/O Systems. Jo, Heeseung

Operating Systems. Steven Hand. Michaelmas / Lent Term 2008/ lectures for CST IA. Handout 4. Operating Systems

or edit a file, our immediate interest is to read or enter some information, not to compute an answer.

I/O. CS 416: Operating Systems Design Department of Computer Science Rutgers University

Input-Output (I/O) Input - Output. I/O Devices. I/O Devices. I/O Devices. I/O Devices. operating system must control all I/O devices.

CS370 Operating Systems

-Device. -Physical or virtual thing that does something -Software + hardware to operate a device (Controller runs port, Bus, device)

Today: I/O Systems. Architecture of I/O Systems

CS 134. Operating Systems. April 8, 2013 Lecture 20. Input/Output. Instructor: Neil Rhodes. Monday, April 7, 14

Answer to exercises chap 13.2

UNIT-7. Overview of Mass Storage Structure

Input Output (IO) Management

Principles of Operating Systems CS 446/646

Chapter 7: Mass-storage structure & I/O systems. Operating System Concepts 8 th Edition,

Operating System 1 (ECS-501)

CSE 120. Overview. July 27, Day 8 Input/Output. Instructor: Neil Rhodes. Hardware. Hardware. Hardware

VIII. Input/Output Operating Systems Prof. Dr. Marc H. Scholl DBIS U KN Summer Term

Input / Output. School of Computer Science G51CSA

CSE 4/521 Introduction to Operating Systems. Lecture 27 (Final Exam Review) Summer 2018

I/O. Fall Tore Larsen. Including slides from Pål Halvorsen, Tore Larsen, Kai Li, and Andrew S. Tanenbaum)

I/O. Fall Tore Larsen. Including slides from Pål Halvorsen, Tore Larsen, Kai Li, and Andrew S. Tanenbaum)

I/O and Device Drivers

CSE 451: Operating Systems Winter I/O System. Gary Kimura

CSCI-GA Operating Systems I/O. Hubertus Franke

5.b Principles of I/O Hardware CPU-I/O communication

CSC 2405: Computer Systems II

Input/Output Problems. External Devices. Input/Output Module. I/O Steps. I/O Module Function Computer Architecture

CS162 Operating Systems and Systems Programming Lecture 16. I/O Systems. Page 1

Chapter 8: Virtual Memory. Operating System Concepts

Operating Systems. V. Input / Output

CS162 Operating Systems and Systems Programming Lecture 17. Disk Management and File Systems

3.1 Introduction. Computers perform operations concurrently

C02: Interrupts and I/O

CIS Operating Systems I/O Systems & Secondary Storage. Professor Qiang Zeng Spring 2018

Chapter 5 Input/Output. I/O Devices

UC Santa Barbara. Operating Systems. Christopher Kruegel Department of Computer Science UC Santa Barbara

Design Overview of the FreeBSD Kernel CIS 657


Design Overview of the FreeBSD Kernel. Organization of the Kernel. What Code is Machine Independent?

Generic Model of I/O Module Interface to CPU and Memory Interface to one or more peripherals

CIS Operating Systems I/O Systems & Secondary Storage. Professor Qiang Zeng Fall 2017

Lecture 1 Introduction (Chapter 1 of Textbook)

INPUT/OUTPUT ORGANIZATION

Computer Architecture CS 355 Busses & I/O System

Computer Organization ECE514. Chapter 5 Input/Output (9hrs)

OPERATING SYSTEMS CS136

CSE398: Network Systems Design

What s An OS? Cyclic Executive. Interrupts. Advantages Simple implementation Low overhead Very predictable

Organisasi Sistem Komputer

CS162 Operating Systems and Systems Programming Lecture 16. Page Allocation and Replacement (con t) I/O Systems

Networks and Opera/ng Systems Chapter 19: I/O Subsystems

Transcription:

Silberschatz and Galvin Chapter 12 I/O Systems CPSC 410--Richard Furuta 3/19/99 1 Topic overview I/O Hardware Application I/O Interface Kernel I/O Subsystem Transforming I/O requests to hardware operations Performance Topics in this chapter review and extend material discussed earlier CPSC 410--Richard Furuta 3/19/99 2 1

I/O hardware Conflicting trends in I/O devices: Ð Standardized software and hardware interfaces Ð Wide variety of hardware devices, some providing unique resources Device driver modules Ð Provide uniform device access interface to the I/O subsystem Ð Analogous to system calls, which provide a standard interface between application and operating system CPSC 410--Richard Furuta 3/19/99 3 I/O hardware Common concepts Ð Port connection point Ð Bus common set of wires and protocol daisy chain (A to B to C to computer) or shared direct access Ð Controller operates port, bus, or a device host adapter: separate circuit board that plugs into computer. Generally contains processor, microcode, some private memory CPSC 410--Richard Furuta 3/19/99 4 2

I/O hardware Controller has one or more registers for data and control signals Processor communicates with controller by reading and writing these registers Ð Specified through use of I/O instructions Direct I/O instructions: Device registers are separate; instructions transfer byte or word to I/O port address Memory-mapped I/O: device control registers mapped into memory space of the processor (e.g., screen memory) CPSC 410--Richard Furuta 3/19/99 5 I/O hardware I/O port registers Ð status bits that are readable by host (e.g., current command has completed, byte ready to be read, device error has occurred) Ð control written by host to start command or change device mode (e.g., full-duplex and half-duplex communications for serial device) Ð data-in read to get input Ð data-out written to send output CPSC 410--Richard Furuta 3/19/99 6 3

I/O hardware: Polling Determines state of device command-ready bit in control register busy bit in status register error bit in status register Busy-wait cycle to wait for I/O from device CPSC 410--Richard Furuta 3/19/99 7 I/O hardware: Polling Example of writing output Host repeatedly reads busy bit until that bit becomes clear (busy waiting or polling here) Host sets write bit in control register and writes byte into data-out register Host sets command-ready bit in control register When controller detects command-ready bit, sets busy bit Controller reads command register and sees write bit. Reads data-out register to get the byte and performs I/O to the device Controller clears command-ready, error (command succeeded), and busy (controller finished) CPSC 410--Richard Furuta 3/19/99 8 4

I/O hardware: interrupts CPU Interrupt request line triggered by I/O device (sensed after executing every instruction) Interrupt handler receives interrupts; return from interrupt instruction returns CPU to state prior to interrupt Terminology: Ð device controller raises interrupt Ð CPU catches interrupt and dispatches to the interrupt handler Ð Interrupt handler clears interrupt after servicing CPSC 410--Richard Furuta 3/19/99 9 I/O hardware: interrupts CPUs have two interrupt request lines: maskable and nonmaskable Ð Maskable to ignore or delay some interrupts Interrupt vector (offset in table) to dispatch interrupt to correct handler Ð Based on priority: defers low-priority interupts to higher-priority ones Ð Some unmaskable Interrupt mechanism also used for exceptions (e.g., divide by zero) CPSC 410--Richard Furuta 3/19/99 10 5

Interrupt-driven I/O cycle CPSC 410--Richard Furuta 3/19/99 11 Direct Memory Access Used to avoid programmed I/O for large data movement Ð programmed I/O: CPU transfers data to/from device one byte at a time, watching status bits, etc. Requires DMA controller Bypasses CPU to transfer data directly between I/O device and memory Ð DMA command block contains pointer to source of transfer, pointer to destination of transfer, number of bytes to be transferred Ð DMA controller manages transfer, communicating with device controller, while CPU carries out other work. Cycle stealing (DMA controller seizes memory bus) can slow down CPU. Ð DMA controller interrupts CPU at conclusion of transfer CPSC 410--Richard Furuta 3/19/99 12 6

Steps in DMA transfer CPSC 410--Richard Furuta 3/19/99 13 Application I/O interface Generalized device interfaces implemented by device drivers (for specific devices) Ð Abstraction, encapsulation, software layering Devices vary in many dimensions Ð Data transfer mode: character/block Ð Access method: sequential/random Ð Transfer schedule: synchronous/asynchronous Ð Sharing: sharable/dedicated Ð Speed of operation: latency/seek time/transfer rate/delay between operations Ð I/O direction: read/write/read-write CPSC 410--Richard Furuta 3/19/99 14 7

Application I/O interface Major access conventions for device access Ð block I/O Ð character-stream I/O Ð memory-mapped file access Ð network sockets Escape or back-door system calls Ð transparently pass arbitrary commands to device driver Ð Unix ioctl (I/O ConTroL) CPSC 410--Richard Furuta 3/19/99 15 Application I/O interface: Block and Character Devices Block devices include disk drives Ð Commands include read, write, seek Ð Raw I/O or file-system access (access device as a simple linear array of blocks) Ð Memory-mapped file access possible (operations are as if reading/writing to memory) Character devices include keyboards, mice, serial ports Ð Commands include get, put (character at a time) Ð Libraries layered on top allow line editing CPSC 410--Richard Furuta 3/19/99 16 8

Application I/O interface: Network devices Varying enough from block (read-write-seek) and character (get-put) to have own interface Unix and Windows/NT include socket interface Ð Applications can create sockets, connect local socket to remote address, listen for remote applications to connect to local socket, send and receive packets over the connection Ð Separates network protocol from network operations Ð Includes select functionality; which sockets have a packet waiting and which have room to accept a packet to be set Approaches vary widely (pipes, FIFOs, streams, queues, mailboxes) CPSC 410--Richard Furuta 3/19/99 17 Application I/O interface: Clocks and timers Provide current time, elapsed time, timer to trigger operation X at time T programmable interval timer used for timings, periodic interrupts Ð waits for specified time and then generates an interrupt (once or many times) ioctl (on UNIX) covers odd aspects of I/O such as clocks and timers CPSC 410--Richard Furuta 3/19/99 18 9

Application I/O interface: Blocking and nonblocking I/O Blocking - process suspended until I/O completed Ð Easy to use and understand Ð Insufficient for some needs Nonblocking - I/O call returns as much as available Ð User interface, data copy (buffered I/O) Ð Implemented via multi-threading Ð Returns quickly with count of bytes read or written Asynchronous - process runs while I/O executes Ð Difficult to use Ð I/O subsystem signals process when I/O completed either by setting a variable, with a software interrupt, with a callback routine, etc. CPSC 410--Richard Furuta 3/19/99 19 Scheduling Kernel I/O subsystem Ð Rearranging the order of service with goal of improving overall system performance (see Chapter 13) Ð Some I/O request ordering via per-device queue Ð Some OSs try fairness CPSC 410--Richard Furuta 3/19/99 20 10

Kernel I/O subsystem Buffering - store data in memory while transfering between devices Ð To cope with device speed mismatch Example: double buffering; write one while transferring other Ð To cope with device transfer size mismatch Example: fragmentation and reassembly of (relatively smallsized) network packets Ð To maintain Òcopy semanticsó Example: with DMA, what happens if an application changes the memory copy before a write completes? Here, application data is copied into a kernel buffer before returning control to application CPSC 410--Richard Furuta 3/19/99 21 Kernel I/O subsystem Caching - fast memory holding copy of data Ð Always just a copy Ð Key to performance (see Chapter 17) CPSC 410--Richard Furuta 3/19/99 22 11

Kernel I/O subsystem Spooling - holds output for a device Ð If device can serve only one request at a time Ð Example: Printing Device reservation - provides exclusive access to a device Ð System calls for allocation and deallocation Ð May be left up to application to watch out for deadlock CPSC 410--Richard Furuta 3/19/99 23 Kernel I/O subsystem Error handling Ð OS can recover from disk read, device unavailable, transient write failures Example: read retry, network resend, etc. Ð Permanent device failures require notification Most return an error number or code when I/O request fails System error logs hold problem reports Example: Unix errno variable CPSC 410--Richard Furuta 3/19/99 24 12

Kernel I/O subsystem 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 Some use object-oriented methods and message passing to implement I/O CPSC 410--Richard Furuta 3/19/99 25 Transforming 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 CPSC 410--Richard Furuta 3/19/99 26 13

Blocking I/O request CPSC 410--Richard Furuta 3/19/99 27 Performance I/O a major factor in system performance Ð Demands CPU to execute device driver, kernel I/O code Ð Context switches due to interrupts (switches necessary to execute the interrupt handler and to restore state) Ð Data copying Ð Network traffic especially stressful (see example on next slide) CPSC 410--Richard Furuta 3/19/99 28 14

Performance: Intercomputer communications CPSC 410--Richard Furuta 3/19/99 29 Improving performance Reduce number of context switches Reduce data copying Reduce interrupts by using large transfers, smart controllers, polling Use DMA Balance CPU, memory, bus, and I/O performance for highest throughput CPSC 410--Richard Furuta 3/19/99 30 15

Implementation tradeoffs Application level implementation Ð more flexible, less likely to cause system crashes Ð inefficient because of context switch overhead, layers of abstraction Kernel implementation Ð can improve performance Ð more challenging to implement Ð greater debugging needed to avoid data corruption and system crashes Hardware implementation Ð highest performance Ð difficult and expensive to make further improvements or bug fixes Ð increased development time (months vs days) Ð decreased flexibility (e.g., canõt necessarily take advantage of knowledge in the kernel) CPSC 410--Richard Furuta 3/19/99 31 16