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

Similar documents
Device-Functionality Progression

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

Chapter 13: I/O Systems

Module 12: I/O Systems

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

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

Module 12: I/O Systems

Chapter 13: I/O Systems

Chapter 13: I/O Systems

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

Chapter 13: I/O Systems

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

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.

by I.-C. Lin, Dept. CS, NCTU. Textbook: Operating System Concepts 8ed CHAPTER 13: 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

Module 11: I/O Systems

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

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

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

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

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

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

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

Chapter 13: I/O Systems

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

Input/Output Systems

I/O Systems. Jo, Heeseung

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

NWI-IBC019: Operating systems

I/O AND DEVICE HANDLING Operating Systems Design Euiseong Seo

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

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

I/O SYSTEMS. Sunu Wibirama

Lecture 15: I/O Devices & Drivers

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

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

Operating Systems. V. Input / Output

[08] IO SUBSYSTEM 1. 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)

Silberschatz and Galvin Chapter 12

Scuola Superiore Sant Anna. I/O subsystem. Giuseppe Lipari

CS370 Operating Systems

Operating Systems 2010/2011

OPERATING SYSTEMS CS136

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

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

Input/Output Systems

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

CS370 Operating Systems

Operating Systems. Lecture 09: Input/Output Management. Elvis C. Foster

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

CS420: Operating Systems. Kernel I/O Subsystem

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

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

C02: Interrupts and I/O

I/O Management and Disk Scheduling. Chapter 11

Chapter 1: Introduction

Introduction. CS3026 Operating Systems Lecture 01

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

Input Output (IO) Management

Principles of Operating Systems CS 446/646

Last class: Today: Course administration OS definition, some history. Background on Computer Architecture

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

Chapter 5 Input/Output. I/O Devices

CS510 Operating System Foundations. Jonathan Walpole

CSCI-GA Operating Systems I/O. Hubertus Franke

Input/Output Management

Introduction to I/O. 1-Slide Overview to File Management

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

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

Chapter 5 - Input / Output

QUIZ Ch.6. The EAT for a two-level memory is given by:

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

Last 2 Classes: Introduction to Operating Systems & C++ tutorial. Today: OS and Computer Architecture

Operating Systems: Principles and Practice. Mark Zbikowski Gary Kimura (kudos to Tom Anderson)

I/O Management Intro. Chapter 5

Answer to exercises chap 13.2

Operating Systems CMPSC 473. Input/Output April 22, Lecture 22 Instructor: Trent Jaeger

Computer System Overview

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

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

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

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

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

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

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

Introduction to Computer Systems and Operating Systems

CS 450 Fall xxxx Final exam solutions. 2) a. Multiprogramming is allowing the computer to run several programs simultaneously.

SAZ4B/SAE5A Operating System Unit : I - V

What Operating Systems Do An operating system is a program hardware that manages the computer provides a basis for application programs acts as an int

Course Details. Operating Systems with C/C++ Course Details. What is an Operating System?

Operating System 1 (ECS-501)

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

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

Transcription:

Today: I/O Systems How does I/O hardware influence the OS? What I/O services does the OS provide? How does the OS implement those services? How can the OS improve the performance of I/O? Lecture 20, page 1 Architecture of I/O Systems Key components System bus: allows the device to communicate with the CPU, typically shared by multiple devices. A device port typically consisting of 4 registers: Status indicates a device busy, data ready, or error condition Control: command to perform Data-in: data being sent from the device to the CPU Data-out: data being sent from the CPU to the device Controller: receives commands from the system bus, translates them into device actions, and reads/writes data onto the system bus. The device itself Traditional devices: disk drive, printer, keyboard, modem, mouse, display Non-traditional devices: joystick, robot actuators, flying surfaces of an airplane, fuel injection system of a car,... Lecture 20, page 2

PCI Bus Structure Lecture 20, page 3 Kernel I/O Subsystem Lecture 20, page 4

Device I/O Port location on PCs Lecture 20, page 5 I/O Services Provided by OS Naming of files and devices. (On Unix, devices appear as files in the /dev directory) Access control. Operations appropriate to the files and devices. Device allocation. Buffering, caching, and spooling to allow efficient communication with devices. I/O scheduling. Error handling and failure recovery associated with devices (command retries, for example). Device drivers to implement device-specific behaviors. Lecture 20, page 6

Communication using Polling CPU busy-waits until the status is idle. CPU sets the command register and data-out if it is an output operation. CPU sets status to command-ready => controller sets status to busy. Controller reads the command register and performs the command, placing a value in data-in if it is an input command. If the operation succeeds, the controller changes the status to idle. CPU observes the change to idle and reads the data if it was an input operation. Good choice if data must be handled promptly, like for a modem or keyboard. What happens if the device is slow compared to the CPU? Lecture 20, page 7 Communication using Interrupts Rather than using busy waiting, the device can interrupt the CPU when it completes an I/O operation. On an I/O interrupt: Determine which device caused the interrupt. If the last command was an input operation, retrieve the data from the device register. Start the next operation for that device. Lecture 20, page 8

Intel X86 Event Vectors Lecture 20, page 9 Direct Memory Access For devices that transfer large volumes of data at a time (like a disk block), it is expensive to have the CPU retrieve these one byte at a time. Solution: Direct memory access (DMA) Use a sophisticated DMA controller that can write directly to memory. Instead of data-in/data-out registers, it has an address register. The CPU tells the DMA the locations of the source and destination of the transfer. The DMA controller operates the bus and interrupts the CPU when the entire transfer is complete, instead of when each byte is ready. The DMA controller and the CPU compete for the memory bus, slowing down the CPU somewhat, but still providing better performance than if the CPU had to do the transfer itself. Lecture 20, page 10

Application Programmer's View of I/O Devices The OS provides a high-level interface to devices, greatly simplifying the programmer's job. Standard interfaces are provided for related devices. Device dependencies are encapsulated in device drivers. New devices can be supported by providing a new device driver. Device characteristics: Transfer unit: character or block Access method: sequential or random access Timing: synchronous or asynchronous. Most devices are asynchronous, while I/O system calls are synchronous => The OS implements blocking I/O Sharable or dedicated Speed Operations: Input, output, or both Examples: keyboard (sequential, character), disk (block, random or sequential) Lecture 20, page 11 Examples of I/O Device types Lecture 20, page 12

Block and Character devices Block devices include disk drives Commands include read, write, seek Raw I/O or file-system access Memory-mapped file access possible Character devices include keyboards, mice, serial ports Commands include get, put Libraries layered on top allow line editing Lecture 20, page 13 I/O Buffering I/O devices typically contain a small on-board memory where they can store data temporarily before transferring to/from the CPU. A disk buffer stores a block when it is read from the disk. It is transferred over the bus by the DMA controller into a buffer in physical memory. The DMA controller interrupts the CPU when the transfer is done. Lecture 20, page 14

Why buffer on the OS side? To cope with speed mismatches between device and CPU. Example: Compute the contents of a display in a buffer (slow) and then zap the buffer to the screen (fast) To cope with devices that have different data transfer sizes. Example: ftp brings the file over the network one packet at a time. Stores to disk happen one block at a time. To minimize the time a user process is blocked on a write. Writes => copy data to a kernel buffer and return control to the user program. The write from the kernel buffer to the disk is done later. Lecture 20, page 15 Caching Improve disk performance by reducing the number of disk accesses. Idea: keep recently used disk blocks in main memory after the I/O call that brought them into memory completes. Example: Read (diskaddress) If (block in memory) return value from memory Else ReadSector(diskAddress) Example: Write (diskaddress) If (block in memory) update value in memory Else Allocate space in memory, read block from disk, and update value in memory What should happen when we write to a cache? write-through policy (write to all levels of memory containing the block, including to disk). High reliability. write-back policy (write only to the fastest memory containing the block, write to slower memories and disk sometime later). Faster. Lecture 20, page 16

Putting the Pieces Together - a Typical Read Call 1. User process requests a read from a device. 2. OS checks if data is in a buffer. If not, a) OS tells the device driver to perform input. b) Device driver tells the DMA controller what to do and blocks itself. c) DMA controller transfers the data to the kernel buffer when it has all been retrieved from the device. d) DMA controller interrupts the CPU when the transfer is complete. 3. OS transfers the data to the user process and places the process in the ready queue. 4. When the process gets the CPU, it begins execution following the system call. Lecture 20, page 17 Steps in DMA transfer Lecture 20, page 18

I/O request Lifecycle Lecture 20, page 19 Summary I/O is expensive for several reasons: Slow devices and slow communication links Contention from multiple processes. I/O is typically supported via system calls and interrupt handling, which are slow. Approaches to improving performance: Reduce data copying by caching in memory Reduce interrupt frequency by using large data transfers Offload computation from the main CPU by using DMA controllers. Increase the number of devices to reduce contention for a single device and thereby improve CPU utilization. Increase physical memory to reduce amount of time paging and thereby improve CPU utilization. Lecture 20, page 20