Chapter 13: I/O Systems

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

Module 12: I/O Systems

Device-Functionality Progression

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

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

Chapter 13: I/O Systems

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

Chapter 13: I/O Systems

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

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

Chapter 13: I/O Systems

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

Input/Output Systems

Chapter 13: I/O Systems

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

I/O AND DEVICE HANDLING Operating Systems Design Euiseong Seo

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

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

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

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)

CS420: Operating Systems. Kernel I/O Subsystem

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

Silberschatz and Galvin Chapter 12

I/O SYSTEMS. Sunu Wibirama

Module 11: I/O Systems

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

Lecture 15: I/O Devices & Drivers

Input/Output Systems

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

[08] IO SUBSYSTEM 1. 1

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

Operating Systems 2010/2011

NWI-IBC019: Operating systems

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

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

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

CS370 Operating Systems

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

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

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

UNIT-7. Overview of Mass Storage Structure

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

Chapter 1: Introduction. Operating System Concepts 9 th Edit9on

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

Chapter 1: Introduction. Operating System Concepts 8 th Edition,

Principles of Operating Systems CS 446/646

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

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

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

Input Output (IO) Management

Operating Systems 2010/2011

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

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

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

Chapter 1: Introduction

Chapter 1: Introduction. Chapter 1: Introduction

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

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

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

Chapter 1: Introduction

Operating Systems. V. Input / Output

Operating System 1 (ECS-501)

I/O Systems. Jo, Heeseung

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

CS420: Operating Systems

CS420: Operating Systems

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

I/O Management and Disk Scheduling. Chapter 11

Lecture 1 Introduction (Chapter 1 of Textbook)

Computer-System Architecture (cont.) Symmetrically Constructed Clusters (cont.) Advantages: 1. Greater computational power by running applications

Four Components of a Computer System. Operating System Concepts 7 th Edition, Jan 12, 2005

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

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

European University of Lefke. Instructor: Dr. Arif SARI

Operating Systems. Overview. Dr Alun Moon. Computing, Engineering and Information Sciences. 27th September 2011

Chapter 3: Processes. Operating System Concepts 8 th Edition,

Chapter 7: Deadlocks. Operating System Concepts 9 th Edition

Page Replacement Algorithms

Module 2: Computer-System Structures. Computer-System Architecture

SAZ4B/SAE5A Operating System Unit : I - V

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)

Chapter 8: Virtual Memory. Operating System Concepts

Chapter 1: Introduction

Dr. Rafiq Zakaria Campus. Maulana Azad College of Arts, Science & Commerce, Aurangabad. Department of Computer Science. Academic Year

Process Description and Control. Chapter 3

Lecture 2: September 9

Operating Systems. Introduction & Overview. Outline for today s lecture. Administrivia. ITS 225: Operating Systems. Lecture 1

Introduction. CS3026 Operating Systems Lecture 01

COSC243 Part 2: Operating Systems

Module 3: Operating-System Structures

Transcription:

Chapter 13: I/O Systems

Chapter 13: I/O Systems I/O Hardware Application I/O Interface Kernel I/O Subsystem Transforming I/O Requests to Hardware Operations Streams Performance 13.2 Silberschatz, Galvin and Gagne 2005

Objectives Explore the structure of an operating system s I/O subsystem Discuss the principles of I/O hardware and its complexity Provide details of the performance aspects of I/O hardware and software 13.3 Silberschatz, Galvin and Gagne 2005

I/O Hardware Incredible variety of I/O devices Common concepts Port Bus (ex. PCI) Peripheral Component Interconnect: an industry-standard bus for attaching peripherals to computers Controller (host adapter) device registers I/O instructions are those that control devices 13.4 Silberschatz, Galvin and Gagne 2005

I/O Instructions How can the processor give commands and data to a controller to accomplish an I/O transfer? The short answer is that the controller has one or more registers for data and control signals. The processor communicates with the controller by reading and writing bit patterns in these registers. One way in which this communication can occur is through the use of special I/O instructions that specify the transfer of a byte or word to an I/O port address. Alternatively the device controller can support memory-mapped I/O. Device-control registers are mapped into the address space of the processor. The CPU executes I/O requests using the standard datatransfer instructions to read and write the device-control registers. 13.5 Silberschatz, Galvin and Gagne 2005

A Typical PC Bus Structure 13.6 Silberschatz, Galvin and Gagne 2005

32 and 64-bit PCI 13.7 Silberschatz, Galvin and Gagne 2005

Device I/O Port Locations on PCs (partial) 13.8 Silberschatz, Galvin and Gagne 2005

I/O Port An I/O port typically consists of four registers, called the (1) status, (2) control, (3) data-in, and (4) data-out registers: The data-in register is read by the host to get input. The data-out register is written by the host to send output. The status register contains bits that can be read by the host. These bits indicate states, such as whether the current command has completed, whether a byte is available to be read from the data-in register, and whether a device error has occurred. The control register can be written by the host to start a command or to change the mode of a device. 13.9 Silberschatz, Galvin and Gagne 2005

Busy Waiting Busy bit The host repeatedly reads the busy bit until that bit becomes clear. State of device: command-ready busy error Busy-wait cycle to wait for I/O from device 13.10 Silberschatz, Galvin and Gagne 2005

Interrupts CPU has an Interrupt-request line triggered by I/O device Interrupt handler receives interrupts Interrupt vector to dispatch interrupts to correct handlers Interrupts have priority Interrupt mechanism also used for exceptions Division by zero 13.11 Silberschatz, Galvin and Gagne 2005

Interrupt-Driven I/O Cycle 13.12 Silberschatz, Galvin and Gagne 2005

Intel Pentium Processor Event-Vector Table 13.13 Silberschatz, Galvin and Gagne 2005

Direct Memory Access Programmed I/O General purpose CPU deals with I/O Wasteful since the CPU is used also for I/O DMA used to avoid programmed I/O for large data movement Requires DMA controller: a special processor Bypasses CPU to transfer data directly between I/O device and memory 13.14 Silberschatz, Galvin and Gagne 2005

Six Step Process to Perform DMA Transfer 13.15 Silberschatz, Galvin and Gagne 2005

Chapter 13: I/O Systems I/O Hardware Application I/O Interface Kernel I/O Subsystem Transforming I/O Requests to Hardware Operations Streams Performance 13.16 Silberschatz, Galvin and Gagne 2005

Application I/O Interface I/O system calls encapsulate device behaviors in generic classes Device-driver layer hides differences among I/O controllers from kernel 13.17 Silberschatz, Galvin and Gagne 2005

A Kernel I/O Structure 13.18 Silberschatz, Galvin and Gagne 2005

Devices Devices vary in many dimensions Character-stream or block Sequential or random-access Synchronous or asynchronous. Sharable or dedicated Speed of operation read-write, read only, or write only 13.19 Silberschatz, Galvin and Gagne 2005

Characteristics of I/O Devices 13.20 Silberschatz, Galvin and Gagne 2005

Block and Character Devices Block devices include disk drives Commands include read, write, seek Raw I/O or file-system access Character devices include keyboards, mice, serial ports Commands include get, put Libraries layered on top allow line editing 13.21 Silberschatz, Galvin and Gagne 2005

Network Devices Varying enough from block and character to have own interface Most OSs provide Network Interfaces Unix and Windows NT/9x/2000 include socket interface Separates network protocol from network operation Includes select functionality Approaches vary widely (pipes, FIFOs, streams, queues, mailboxes) 13.22 Silberschatz, Galvin and Gagne 2005

Clocks and Timers Provide current time, elapsed time, timer to trigger operation Programmable interval timer used for timings, periodic interrupts Timers used by Scheduler Disk I/O subsystem Network subsystem User processes can also use them 13.23 Silberschatz, Galvin and Gagne 2005

Blocking and Nonblocking I/O Blocking - process suspended until I/O completed Easy to use and understand Process moved from run queue to wait queue 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 13.24 Silberschatz, Galvin and Gagne 2005

Two I/O Methods Synchronous Asynchronous 13.25 Silberschatz, Galvin and Gagne 2005

Chapter 13: I/O Systems I/O Hardware Application I/O Interface Kernel I/O Subsystem Transforming I/O Requests to Hardware Operations Streams Performance 13.26 Silberschatz, Galvin and Gagne 2005

Kernel I/O Services Kernels provide many services related to I/O. Several services scheduling buffering caching spooling device reservation error handling are provided by the kernel's I/O subsystem and build on the hardware and device driver infrastructure. The I/O subsystem is also responsible for protecting itself from errant processes and malicious users. 13.27 Silberschatz, Galvin and Gagne 2005

Kernel I/O Subsystem I/O Scheduling Some I/O request ordering Some OSs try fairness 13.28 Silberschatz, Galvin and Gagne 2005

Scheduling can: I/O Scheduling improve overall system performance share device access fairly among processes reduce the average waiting time for I/O to complete. Suppose that a disk arm is near the beginning of a disk and that three applications issue blocking read calls to that disk. Application 1 requests a block near the end of the disk, application 2 requests one near the beginning, and application 3 requests one in the middle of the disk. The operating system can reduce the distance that the disk arm travels by serving the applications in the order 2, 3, 1. Rearranging the order of service in this way is the essence of I/O scheduling. We have seen disk I/O scheduling in the last class 13.29 Silberschatz, Galvin and Gagne 2005

Device-status Table When a kernel supports asynchronous I/O, it must be able to keep track of many I/O requests at the same time. For this purpose, the operating system might attach the wait queue to a device-status table. 13.30 Silberschatz, Galvin and Gagne 2005

Buffering Store data in memory while transferring between devices To cope with device speed mismatch To cope with device transfer size mismatch 13.31 Silberschatz, Galvin and Gagne 2005

Sun Enterprise 6000 Device-Transfer Rates 13.32 Silberschatz, Galvin and Gagne 2005

Caching A cache is a region of fast memory that holds copies of data. Access to the cached copy is more efficient than access to the original. For instance, the instructions of the currently running process are stored on disk, cached in physical memory, and copied again in the CPU's secondary and primary caches. The difference between a buffer and a cache is that a buffer may hold the only existing copy of a data item, whereas a cache, by definition, just holds a copy on faster storage of an item that resides elsewhere. 13.33 Silberschatz, Galvin and Gagne 2005

Spooling A spool is a buffer that holds output for a device, such as a printer that cannot accept interleaved data streams. Although a printer can serve only one job at a time, several applications may wish to print their output concurrently, without having their output mixed together. The operating system solves this problem by intercepting all output to the printer. Each application's output is spooled to a separate disk file. When an application finishes printing, the spooling system queues the corresponding spool file for output to the printer. The spooling system copies the queued spool files to the printer one at a time. In some operating systems, spooling is managed by a system daemon process. 13.34 Silberschatz, Galvin and Gagne 2005

Device reservation Device reservation - provides exclusive access to a device System calls for allocation and deallocation Watch out for deadlock 13.35 Silberschatz, Galvin and Gagne 2005

Error Handling OS can recover from disk read, device unavailable or write failures Most return an error number or code when I/O request fails System error logs hold problem reports 13.36 Silberschatz, Galvin and Gagne 2005

I/O Protection User process may accidentally or purposefully attempt to disrupt normal operation via illegal I/O instructions!!! Solution: All I/O instructions defined to be privileged Thus I/O must be performed via system calls This way the OS can check them 13.37 Silberschatz, Galvin and Gagne 2005

Use of a System Call to Perform I/O 13.38 Silberschatz, Galvin and Gagne 2005

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 13.39 Silberschatz, Galvin and Gagne 2005

UNIX I/O Kernel Structure 13.40 Silberschatz, Galvin and Gagne 2005

Chapter 13: I/O Systems I/O Hardware Application I/O Interface Kernel I/O Subsystem Transforming I/O Requests to Hardware Operations Streams Performance 13.41 Silberschatz, Galvin and Gagne 2005

I/O Requests to Hardware Operations Consider reading a file from disk for a process Determine the device that holds file Translate name to device representation Physically read data from disk into buffer Make data available to requesting process Return control to process 13.42 Silberschatz, Galvin and Gagne 2005

Life Cycle of An I/O Request 13.43 Silberschatz, Galvin and Gagne 2005

Chapter 13: I/O Systems I/O Hardware Application I/O Interface Kernel I/O Subsystem Transforming I/O Requests to Hardware Operations Streams Performance 13.44 Silberschatz, Galvin and Gagne 2005

STREAMS STREAM a full-duplex communication channel between a user-level process and a device in Unix System V and beyond A STREAM consists of: - STREAM head interfaces with the user process - driver end interfaces with the device - zero or more STREAM modules between them Modules provide the functionality of STREAMS processing Each module contains a read queue and a write queue Message passing is used to communicate between queues 13.45 Silberschatz, Galvin and Gagne 2005

The STREAMS Structure 13.46 Silberschatz, Galvin and Gagne 2005

Chapter 13: I/O Systems I/O Hardware Application I/O Interface Kernel I/O Subsystem Transforming I/O Requests to Hardware Operations Streams Performance 13.47 Silberschatz, Galvin and Gagne 2005

Performance I/O a major factor in system performance: Demands CPU to execute device driver, kernel I/O code Context switches due to interrupts Data copying Network traffic especially stressful 13.48 Silberschatz, Galvin and Gagne 2005

Intercomputer Communications 13.49 Silberschatz, Galvin and Gagne 2005

Improving Performance Reduce number of context switches Reduce data copying Reduce interrupts by using large transfers and smart controllers Use DMA to offload a part of data copying from the CPU Balance CPU, memory, bus, and I/O performance for highest throughput An overload of one these will cause the idleness in others 13.50 Silberschatz, Galvin and Gagne 2005

Device-Functionality Progression Where should the I/O functionality be implemented? Development time 13.51 Silberschatz, Galvin and Gagne 2005

End of Chapter 13

GOOD LUCK 13.53 Silberschatz, Galvin and Gagne 2005