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

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

I/O Systems. Jo, Heeseung

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

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

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

Device-Functionality Progression

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

Chapter 13: I/O Systems

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

Chapter 13: I/O Systems

Module 12: I/O Systems

OPERATING SYSTEMS CS136

I/O AND DEVICE HANDLING Operating Systems Design Euiseong Seo

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

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

Chapter 5 Input/Output. I/O Devices

Silberschatz and Galvin Chapter 12

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

Input/Output Systems

Lecture 15: I/O Devices & Drivers

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

CS370 Operating Systems

Chapter 13: I/O Systems

CS370 Operating Systems

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

Chapter 13: I/O Systems

Module 11: I/O Systems

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

I/O SYSTEMS. Sunu Wibirama

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

NWI-IBC019: Operating systems

Answer to exercises chap 13.2

Operating Systems. V. Input / Output

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

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

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

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

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

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

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

Operating Systems, Fall

Chapter 13: I/O Systems

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

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

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

[08] IO SUBSYSTEM 1. 1

Input/Output Systems

Operating Systems 2010/2011

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

Chapter 13: I/O Systems

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

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)

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

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

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.

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

Hardware OS & OS- Application interface

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

CS510 Operating System Foundations. Jonathan Walpole

Chap. 3. Input/Output

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

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

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

Computer System Overview

C02: Interrupts and I/O

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

Organisasi Sistem Komputer

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

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

I/O Design, I/O Subsystem, I/O-Handler Device Driver, Buffering, Disks, RAID January WT 2008/09

CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 09, SPRING 2013

I/O Management Software. Chapter 5

I/O and Device Drivers

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

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

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

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

CSCI-GA Operating Systems I/O. Hubertus Franke

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


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

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

ECE331: Hardware Organization and Design

Input Output (IO) Management

I/O Management and Disk Scheduling. Chapter 11

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

Operating System Design Issues. I/O Management

I/O Management Software. Chapter 5

Computer Architecture CS 355 Busses & I/O System

Input/Output Management

Operating Systems 2010/2011

The Device Driver Interface. Input/Output Devices. System Call Interface. Device Management Organization

Transcription:

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

Today s Topics 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 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

Memory-Mapped I/O (1) Direct I/O Use special I/O instructions to an I/O port address. 7

Memory-Mapped I/O (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

Memory-Mapped I/O (3) Memory-mapped I/O (cont d) Memory-mapped regions should be uncacheable. Memory-mapped device register is vulnerable to accidental modification through the use of incorrect pointers. Protected memory helps to reduce this risk. The system may have a private high-bandwidth bus between CPU and memory. (1) First try memory bus, and then retry other buses. (2) Snoop the memory bus -- I/O devices may not be able to process requests at the speed of the memory can. (3) Filter addresses in the bridge chip. -- I/O ranges should be preloaded at boot time. 9

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. 10

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) 11

Polling vs. Interrupts (3) 12

Polling vs. Interrupts (4) 13

Programmed I/O vs. DMA (1) 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. 14

Programmed I/O vs. DMA (2) DMA modes (1) Cycle stealing The DMA controller sneaks in and steals an occasional bus cycle from the CPU once in a while, delaying it slightly. (2) Burst mode The DMA controller acquires the bus, issues a series of transfers, then releases the bus. More efficient than cycle stealing: acquiring the bus takes time and multiple words can be transferred for the price of one bus acquisition. It can block the CPU and other devices too long. 15

Programmed I/O vs. DMA (3) Addressing in DMA (1) Physical address OS converts the virtual address of the intended memory buffer into a physical address and writes it into DMA controller s address register. (2) Virtual address The DMA controller must use the MMU to have the virtual-tophysical translation done. Not common: only when the MMU is part of the memory rather than part of the CPU. In any case, the target memory region should be pinned (not paged out) during DMA. 16

Programmed I/O vs. DMA (4) DMA types (1) Sequential DMA Data temporarily stored in DMA controller. Requires an extra bus cycle per word transferred. More flexible in that it can also perform device-to-device copies and even memory-to-memory copies. (2) Simultaneous DMA (or fly-by mode) The DMA controller tells the device controller to transfer the data directly to main memory. 17

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. 18

Goals of I/O Software Goals Device independence Programs can access any I/O device without specifying device in advance. Uniform naming Name of a file or device should simply be a string or an integer. Error handling Handle as close to the hardware as possible. Synchronous vs. asynchronous blocked transfers vs. interrupt-driven Buffering Data coming off a device cannot be stored in final destination. Sharable vs. dedicated devices Disks vs. tape drives Unsharable devices introduce problems such as deadlocks. 19

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

Interrupt Handlers Handling interrupts Critical actions Reenable interrupts : Acknowledge an interrupt to the PIC. : Reprogram the PIC or the device controller. : Update data structures accessed by both the device and the processor. Noncritical actions : Update data structures that are accessed only by 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) 21

Device Drivers 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). 22

Device-Independent I/O Software (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. 23

Device-Independent I/O Software (2) 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 Software (3) 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 Software (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