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

Similar documents
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

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)

Device-Functionality Progression

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

Module 12: I/O Systems

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

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

Module 12: I/O Systems

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

Chapter 13: I/O Systems

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

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

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

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

Chapter 13: I/O Systems

Input/Output Systems

Module 11: I/O Systems

Silberschatz and Galvin Chapter 12

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

I/O SYSTEMS. Sunu Wibirama

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

Chapter 13: I/O Systems

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

I/O AND DEVICE HANDLING Operating Systems Design Euiseong Seo

[08] IO SUBSYSTEM 1. 1

Lecture 15: I/O Devices & Drivers

Input/Output Systems

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

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

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

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

I/O Systems. Jo, Heeseung

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.

Operating Systems 2010/2011

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

Operating Systems. V. Input / Output

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

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

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)

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

CS370 Operating Systems

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

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

CS420: Operating Systems. Kernel I/O Subsystem

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

Input Output (IO) Management

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)

CS370 Operating Systems

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

Operating Systems. V. Input / Output. Eurecom

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

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

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

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

Operating Systems 2010/2011

C02: Interrupts and I/O

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

NWI-IBC019: Operating systems

Principles of Operating Systems CS 446/646

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

Chapter 5 - Input / Output

Chapter 5 Input/Output. I/O Devices

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

Operating System 1 (ECS-501)

Input / Output. School of Computer Science G51CSA

I/O Management and Disk Scheduling. Chapter 11

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

CSE 380 Computer Operating Systems

Hardware OS & OS- Application interface

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

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

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

7/20/2008. What Operating Systems Do Computer-System Organization

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

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

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

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

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

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

I/O and Device Drivers

INPUT/OUTPUT ORGANIZATION

Computer System Overview

Recap from last class

Computer Architecture CS 355 Busses & I/O System

QUESTION BANK UNIT I

Answer to exercises chap 13.2

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

CIS 21 Final Study Guide. Final covers ch. 1-20, except for 17. Need to know:

Part I Overview Chapter 1: Introduction

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

Introduction. CS3026 Operating Systems Lecture 01

Transcription:

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

Outline Overview I/O Hardware I/O Methods Kernel I/O Subsystem Performance Application Interface Operating System Concepts NTHU LSA Lab 2

Overview The two main jobs of a computer I/O and Computation I/O devices: tape, HD, mouse, joystick, network card, screen, flash disks, etc I/O subsystem: the methods to control all I/O devices Two conflicting trends Standardization of HW/SW interfaces Board variety of I/O devices Operating System Concepts NTHU LSA Lab 3

Overview Device drivers: a uniform device-access interface to the I/O subsystem Similar to system calls between apps and OS Device categories Storage devices: disks, tapes Transmission devices: network cards, modems Human-interface devices: keyboard, screen, mouse Specialized devices: joystick, touchpad Operating System Concepts NTHU LSA Lab 4

I/O Hardware Port: A connection point between I/O devices and the host E.g.: USB ports Bus: A set of wires and a well-defined protocol that specifies messages sent over the wires E.g.: PCI bus Controller: A collection of electronics that can operate a port, a bus, or a device A controller could have its own processor, memory, etc. (E.g.: SCSI controller) Operating System Concepts NTHU LSA Lab 5

Typical PC Bus Structure Operating System Concepts NTHU LSA Lab 6

Basic I/O Method (Port-mapped I/O) Each I/O port (device) is identified by a unique port address Each I/O port consists of four registers (1~4Bytes) Data-in register: read by the host to get input Data-out register: written by the host to send output Status register: read by the host to check I/O status Control register: written by the host to control the device Program interact with an I/O port through special I/O instructions (different from mem. access) X86: IN, OUT Operating System Concepts NTHU LSA Lab 7

Device I/O Port Locations on PCs (partial) Operating System Concepts NTHU LSA Lab 8

I/O Methods Categorization Depending on how to address a device: Port-mapped I/O Use different address space from memory Access by special I/O instruction (e.g. IN, OUT) Memory-mapped I/O Reserve specific memory space for device Access by standard data-transfer instruction (e.g. MOV) More efficient for large memory I/O (e.g. graphic card) Vulnerable to accidental modification, error Operating System Concepts NTHU LSA Lab 9

I/O Methods Categorization Depending on how to interact with a device: Poll (busy-waiting): processor periodically check status register of a device Interrupt: device notify processor of its completion Depending on who to control the transfer: Programmed I/O: transfer controlled by CPU Direct memory access (DMA) I/O: controlled by DMA controller (a special purpose controller) Design for large data transfer Commonly used with memory-mapped I/O and interrupt I/O method Operating System Concepts NTHU LSA Lab 10

Six-Step Process to Perform DMA (Direct Memory Access) Operating System Concepts NTHU LSA Lab 11

Review Slides ( I ) Definition of I/O port? Bus? Controller? I/O device and CPU communication? Port-mapped vs. Memory-mapped Poll vs. Interrupt Programmed I/O vs. DMA Steps to handle an interrupt I/O and DMA request? Operating System Concepts NTHU LSA Lab 12

Kernel I/O Subsystem Operating System Concepts - NTHU EOS Lab 13

I/O Subsystem I/O Scheduling improve system performance by ordering the jobs in I/O queue e.g. disk I/O order scheduling Buffering store data in memory while transferring between I/O devices Speed mismatch between devices Devices with different data-transfer sizes Support copy semantics Operating System Concepts NTHU LSA Lab 14

I/O Subsystem Caching fast memory that holds copies of data Always just a copy Key to performance Spooling holds output for a device e.g. printing (cannot accept interleaved files) Error handling when I/O error happens e.g. SCSI devices returns error information I/O protection Privileged instructions Operating System Concepts NTHU LSA Lab 15

UNIX I/O Kernel Data Structure Linux treats all I/O devices like a file Operating System Concepts NTHU LSA Lab 16

Device-status Table Operating System Concepts NTHU LSA Lab 17

Blocking and Nonblocking I/O Blocking - process suspended until I/O completed Easy to use and understand Insufficient for some needs Use for synchronous communication & I/O Nonblocking Implemented via multi-threading Returns quickly with count of bytes read or written Use for asynchronous communication & I/O Operating System Concepts NTHU LSA Lab 18

Life Cycle of An I/O Request Check buffer cache Move process from run queue to wait queue Allocate kernel buffer Schedule I/O Physical I/O In buffer Data transfer Operating System Concepts NTHU LSA Lab 19

Performance I/O is a major factor in system performance It places heavy demands on the CPU to execute device driver code The resulting context switches stress the CPU and its hardware caches I/O loads down the memory bus during data copy between controllers and physical memory, Interrupt handling is a relatively expensive task Busy-waiting could be more efficient than interruptdriven if I/O time is small Operating System Concepts NTHU LSA Lab 20

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 Operating System Concepts NTHU LSA Lab 21

Review Slides ( II ) What are the key I/O services Scheduling Cache Buffering Spooling Error handling I/ protection How to improve system performance? Operating System Concepts NTHU LSA Lab 22

Application I/O Interface Operating System Concepts - NTHU EOS Lab 23

A Kernel I/O Structure Device drivers: a uniform device-access interface to the I/O subsystem; hide the differences among device controllers from the I/O sub-system of OS Operating System Concepts NTHU LSA Lab 24

Characteristics of I/O Devices Operating System Concepts NTHU LSA Lab 25

I/O Device Class Device class is fairly standard across different OS Block I/O Char-stream I/O Memory-mapped file access Network sockets Clock & timer interfaces Back-door interfaces (e.g. ioctl() ) Enable an application to access any functionality implemented by a device driver without the need to invent a new system call Operating System Concepts NTHU LSA Lab 26

Block & Char Devices Block devices: disk drives system calls: read( ), write( ), seek( ) Memory-mapped file can be layered on top Char-stream devices: mouse, keyboard, serial ports system calls: get( ), put( ) Libraries layered on top allow line editing Operating System Concepts NTHU LSA Lab 27

Network Devices Varying enough from block and character to have own interface System call: send(), recv(), select() select() returns which socket is waiting to send or receive, eliminates the need of busy waiting Many other approaches pipes, FIFOS, STREAMS, message queues Operating System Concepts NTHU LSA Lab 28

Reading Material & HW 13.1 13.6 Problem Set 13.2 13.5 13.6 13.8 Operating System Concepts NTHU LSA Lab 29

Interrupt Vector Table Intel Pentium Processor: Operating System Concepts NTHU LSA Lab 30

CPU and device Interrupt handshake 1. Device asserts interrupt request (IRQ) 2. CPU checks the interrupt request line at the beginning of each instruction cycle 3. Save the status and address of interrupted process 4. CPU acknowledges the interrupt and search the interrupt vector table for interrupt handler routines 5. CPU fetches the next instruction from the interrupt handler routine 6. Restore interrupted process after executing interrupt handler routine Operating System Concepts NTHU LSA Lab 31

Interrupt Prioritization Maskable interrupt: interrupt with priority lower than current priority is not recognized until pending interrupt is complete Non-maskable interrupt (NMI): highestpriority, never masked Often used for power-down, memory error Operating System Concepts NTHU LSA Lab 32

Interrupt-Driven I/O CPU 1 device driver initiates I/O 2 Controller 7 CPU executing checks for interrupts between instructions CPU receiving interrupt, transfers control to Interrupt handler 5 interrupt handler processes data, returns from interrupt 6 CPU resumes processing of interrupted task initiates I/O input ready, output complete, or error Generates interrupt signal Operating System Concepts NTHU LSA Lab 33 4 3

Summary of Services in I/O Subsystem The management of the name space for files and devices Access control to files and devices Operation control File system space allocation Disk allocation Buffering, caching, and spooling I/O scheduling Device status monitoring, error handling, and failure recovery Device driver configuration and initialization Operating System Concepts NTHU LSA Lab 34

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 Operating System Concepts NTHU LSA Lab 35

Layered File System revisited file name Application Programs write(data_file, item) Logical File System information of data_file File-Organization Module 2144th block Basic File System Given a symbolic file name, use directory to provide values needed by FOM Transform logical address to physical block address Numeric disk address driver 1, cylinder 73, surface 2, sector 10 I/O Control Driver: hardware instructions Devices Operating System Concepts NTHU LSA Lab 36

Intercomputer Communications Network traffic could cause high context switch rate Interrupt generated during keyboard & network I/O Context switch occurs between prog. & kernel (drivers) keyboard e.g. telnet session e.g. telnet Operating System Concepts NTHU LSA Lab 37

STREAMS A full-duplex communication channel between a user-level process and a device STREAM provides a framework for a modular and incremental approach to writing device drivers and network protocols Operating System Concepts NTHU LSA Lab 38

The STREAM Structure A STREAM consists of STREAM head interfaces with user process Driver end interfaces with the device zero or more STREAM modules between them Each module contains a read and a write queue Message passing is used to communicate between queues Operating System Concepts NTHU LSA Lab 39