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

Similar documents
I/O Systems. Jo, Heeseung

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

I/O & Storage. Jin-Soo Kim ( Computer Systems Laboratory Sungkyunkwan University

Hard Disk Drives (HDDs)

Device-Functionality Progression

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

Module 12: I/O Systems

Chapter 13: I/O Systems

I/O AND DEVICE HANDLING Operating Systems Design Euiseong Seo

Chapter 13: I/O Systems

Input/Output Systems

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

Hard Disk Drives (HDDs) Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

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

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)

Module 12: I/O Systems

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

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

Chapter 13: I/O Systems

Silberschatz and Galvin Chapter 12

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

Chapter 13: I/O Systems

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

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

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

NWI-IBC019: Operating systems

Module 11: I/O Systems

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

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

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

Lecture 15: I/O Devices & Drivers

Input/Output Systems

Chapter 5 Input/Output. I/O Devices

Chapter 13: I/O Systems

Answer to exercises chap 13.2

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

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

Chapter 13: I/O Systems

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

Operating Systems. V. Input / Output

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

I/O SYSTEMS. Sunu Wibirama

CS370 Operating Systems

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

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

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

[08] IO SUBSYSTEM 1. 1

Chapter 13: I/O Systems

CS370 Operating Systems

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

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.

19: I/O. Mark Handley. Direct Memory Access (DMA)

Discussion Week 8. TA: Kyle Dewey. Tuesday, November 15, 11

Operating Systems, Fall

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

OPERATING SYSTEMS CS136

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

CSCI-GA Operating Systems I/O. Hubertus Franke

Input / Output. School of Computer Science G51CSA

Chapter-6. SUBJECT:- Operating System TOPICS:- I/O Management. Created by : - Sanjay Patel

I/O Management Software. Chapter 5

Hardware OS & OS- Application interface

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

Operating System Design Issues. I/O Management

Operating Systems (CS1022) Input/Output. Yagiz Özbek Evren

Ricardo Rocha. Department of Computer Science Faculty of Sciences University of Porto

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

Operating Systems. V. Input / Output. Eurecom

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

Chap. 3. Input/Output

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

I/O Management Software. Chapter 5

I/O Management and Disk Scheduling. Chapter 11

CIS Operating Systems File Systems. Professor Qiang Zeng Fall 2017

CIS Operating Systems File Systems. Professor Qiang Zeng Spring 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)

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

Input/Output Management

Ausgewählte Betriebssysteme - Mark Russinovich & David Solomon (used with permission of authors)

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

QUESTION BANK UNIT I

File System Implementation

Input Output (IO) Management

C02: Interrupts and I/O

I/O and Device Drivers

Computer Organization and Structure. Bing-Yu Chen National Taiwan University

Paging. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

Input/Output. Today. Next. ! Principles of I/O hardware & software! I/O software layers! Secondary storage. ! File systems

Computer System Overview

OPERATING SYSTEM OVERVIEW

Computer System Overview OPERATING SYSTEM TOP-LEVEL COMPONENTS. Simplified view: Operating Systems. Slide 1. Slide /S2. Slide 2.

Input/Output. Today. Next. Principles of I/O hardware & software I/O software layers Disks. Protection & Security

Introduction. Operating Systems. Outline. Hardware. I/O Device Types. Device Controllers. (done)

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

Organisasi Sistem Komputer

Transcription:

I/O Systems Jinkyu Jeong (jinkyu@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu

Today s Topics Device characteristics Block device vs. Character device Direct I/O vs. Memory-mapped I/O Polling vs. Interrupts Programmed I/O vs. DMA Blocking vs. Non-blocking I/O I/O software layers 2

A Typical PC Bus Structure 3

I/O Devices (1) Block device Stores information in fixed-size blocks, each one with its own address. 512B 32KB per block It is possible to read or write each block independently of all the other ones. Disks, tapes, etc. Character device Delivers or accepts a stream of characters. Not addressable and no seek operation. Printers, networks, mice, keyboards, etc. 4

I/O Devices (2) USB 2.0: 60 MB/s 5

I/O Devices (3) Device controller (or host adapter) I/O devices have components: Mechanical component Electronic component The electronic component is the device controller. May be able to handle multiple devices. Controller s tasks Convert serial bit stream to block of bytes. Perform error correction as necessary. Make available to main memory. 6

Accessing I/O Devices (1) Direct I/O Use special I/O instructions to an I/O port address. 7

Accessing I/O Devices (2) Memory-mapped I/O The device control registers are mapped into the address space of the processor. The CPU executes I/O requests using the standard data transfer instructions. I/O device drivers can be written entirely in C. No special protection mechanism is needed to keep user processes from performing I/O Can give a user control over specific devices but not others by simply including the desired pages in its page table. Reading a device register and testing its value is done with a single instruction. 8

Polling vs. Interrupts (1) Polled I/O CPU asks ( polls ) devices if need attention. ready to receive a command command status, etc. Advantages Simple Software is in control. Efficient if CPU finds a device to be ready soon. Disadvantages Inefficient in non-trivial system (high CPU utilization). Low priority devices may never be serviced. 9

Polling vs. Interrupts (2) Interrupt-driven I/O I/O devices request interrupt when need attention. Interrupt service routines specific to each device are invoked. Interrupts can be shared between multiple devices. Advantages CPU only attends to device when necessary. More efficient than polling in general. Disadvantages Excess interrupts slow (or prevent) program execution. Overheads (may need 1 interrupt per byte transferred) 10

Polling vs. Interrupts (3) 11

Polling vs. Interrupts (4) 12

Programmed I/O vs. DMA DMA (Direct Memory Access) Bypasses CPU to transfer data directly between I/O device and memory. Used to avoid programmed I/O for large data movement. 13

Blocking vs. Non-Blocking I/O Blocking I/O Process is suspended until I/O completed. Easy to use and understand. Nonblocking I/O I/O call returns quickly, with a return value that indicates how many bytes were transferred. A nonblocking read() returns immediately with whatever data available the full number of bytes requested, fewer, or none at all. 14

Goals of I/O Software Goals Device independence Uniform naming Error handling Synchronous vs. asynchronous Buffering Sharable vs. dedicated devices 15

I/O Software Layers User-level I/O Software Device-independent I/O Software Device Drivers Interrupt Handlers Hardware Network 16

Interrupt Handlers Handling interrupts : Acknowledge an interrupt to the PIC. Critical : Reprogram the PIC or the device controller. actions : Update data structures accessed by both the device Reenable interrupts and the processor. Noncritical : Update data structures that are accessed only by actions the processor. (e.g., reading the scan code from the keyboard) Return from interrupts Noncritical deferred actions : Actions may be delayed. : Copy buffer contents into the address space of some process (e.g., sending the keyboard line buffer to the terminal handler process). : Bottom half (Linux) 17

Device Drivers (1) Device drivers Device-specific code to control each I/O device interacting with device-independent I/O software and interrupt handlers. Requires to define a well-defined model and a standard interface of how they interact with the rest of the OS. Implementing device drivers: Statically linked with the kernel. Selectively loaded into the system during boot time. Dynamically loaded into the system during execution. (especially for hot pluggable devices). 18

Device Drivers (2) 19

Device Drivers (3) The problem Reliability remains a crucial, but unresolved problem 5% of Windows systems crash every day Huge cost of failures: stock exchange, e-commerce, Growing unmanaged systems : digital appliances, consumer electronics devices OS extensions are increasingly prevalent 70% of Linux kernel code Over 35,000 drivers with over 120,000 versions on Windows XP Written by less experienced programmer Extensions are a leading cause of OS failure Drivers cause 85% of Windows XP crashes Drivers are 7 times buggier than the kernel in Linux 20

Device-Independent I/O SW (1) Uniform interfacing for device drivers In Unix, devices are modeled as special files. They are accessed through the use of system calls such as open(), read(), write(), close(), ioctl(), etc. A file name is associated with each device. Major device number locates the appropriate driver. Minor device number (stored in i-node) is passed as a parameter to the driver in order to specify the unit to be read or written. The usual protection rules for files also apply to I/O devices. 21

Device-Independent I/O SW (2) 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 select() to find if data ready then read() or write() to transfer Asynchronous - process runs while I/O executes Difficult to use I/O subsystem signals process when I/O completed 22

Device-Independent I/O SW (2) user user kernel kernel Synchronous Asynchronous 23

Device-Independent I/O SW (3) Buffering (a) Unbuffered (b) Buffered in user space (c) Buffered in the kernel space (d) Double buffering in the kernel 24

Device-Independent I/O SW (4) Error reporting Many errors are device-specific and must be handled by the appropriate driver, but the framework for error handling is device independent. Programming errors vs. actual I/O errors Handling errors Returning the system call with an error code. Retrying a certain number of times. Ignoring the error. Killing the calling process. Terminating the system. 25

Device-Independent I/O SW (4) Allocating and releasing dedicated devices Some devices cannot be shared. (1) Require processes to perform open() s on the special files for devices directly. The process retries if open() fails. (2) Have special mechanisms for requesting and releasing dedicated devices. An attempt to acquire a device that is not available blocks the caller. Device-independent block size Treat several sectors as a single logical block. The higher layers only deal with abstract devices that all use the same block size. 26

User-Space I/O Software Provided as a library Standard I/O library in C fopen() vs. open()? Buffering for fgetc()? Spooling A way of dealing with dedicated I/O devices in a multiprogramming system. Implemented by a daemon and a spooling directory. Printers, network file transfers, USENET news, mails, etc. 27

I/O Systems Layers 28