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

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

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)

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

Module 12: I/O Systems

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

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

Device-Functionality Progression

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

Chapter 13: I/O Systems

Chapter 13: I/O Systems

Module 12: I/O Systems

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

Chapter 13: I/O Systems

Chapter 13: I/O Systems

Chapter 13: I/O Systems

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

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

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

Silberschatz and Galvin Chapter 12

I/O AND DEVICE HANDLING Operating Systems Design Euiseong Seo

Input/Output Systems

Lecture 15: I/O Devices & Drivers

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

CS420: Operating Systems. Kernel I/O Subsystem

Input/Output Systems

I/O SYSTEMS. Sunu Wibirama

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)

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

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

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

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

Module 11: I/O Systems

Operating Systems 2010/2011

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

NWI-IBC019: Operating systems

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

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

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

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

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

Operating Systems 2010/2011

CS370 Operating Systems

[08] IO SUBSYSTEM 1. 1

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

Input Output (IO) Management

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

I/O Systems. Jo, Heeseung

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

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

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

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

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

UNIT-7. Overview of Mass Storage Structure

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

Answer to exercises chap 13.2

Principles of Operating Systems CS 446/646

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

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

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

Operating Systems. V. Input / Output

Common Computer-System and OS Structures

Input / Output. School of Computer Science G51CSA

Unit 2 : Computer and Operating System Structure

Lecture 2: September 9

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

I/O CANNOT BE IGNORED

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

3.1 Introduction. Computers perform operations concurrently

SAZ4B/SAE5A Operating System Unit : I - V

C02: Interrupts and I/O

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

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

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)

Computer Architecture CS 355 Busses & I/O System

Operating System 1 (ECS-501)

Chapter 8: Virtual Memory. Operating System Concepts

INPUT/OUTPUT ORGANIZATION

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

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

I/O and Device Drivers

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

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

Operating systems. Module 15 kernel I/O subsystem. Tami Sorgente 1

Programmed I/O Interrupt-Driven I/O Direct Memory Access (DMA) I/O Processors. 10/12/2017 Input/Output Systems and Peripheral Devices (02-2)

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

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

Reserves time on a paper sign-up sheet. Programmer runs his own program. Relays or vacuum tube hardware. Plug board or punch card input.


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

Computer System Overview

Virtual Memory COMPSCI 386

Transcription:

Che-Wei Chang chewei@mail.cgu.edu.tw Department of Computer Science and Information Engineering, Chang Gung University

l Chapter 10: File System l Chapter 11: Implementing File-Systems l Chapter 12: Mass-Storage Structure l Chapter 13: I/O Systems l Chapter 14: System Protection l Chapter 15: System Security 2

} I/O Hardware } Application I/O Interface } Kernel I/O Subsystem } Transforming I/O Requests to Hardware Operations } Performance 3

} Incredible Variety of I/O Devices Storage Transmission Human-interface } Common Concepts Port: connection point for device Bus: daisy chain or shared direct access Controller (host adapter): electronics that operate port, bus, device 4

5

} Device registers which can be accessed by the host 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 which indicate device states The control register is written by the host to send command } Methods to access devices with their addresses Direct I/O instructions Memory-mapped I/O Device data and command registers mapped to processor address space Especially for large address spaces (graphics) 6

7

} An example of Polling I/O 1. Read busy bit from status register until 0 2. Host sets read or write bit and if write copies data into dataout register 3. Host sets command-ready bit 4. Controller sets busy bit, executes transfer 5. Controller clears busy bit, error bit, command-ready bit when transfer done } Step 1 is busy-wait cycle to wait for I/O from device Reasonable if device is fast But inefficient if device slow CPU switches to other tasks? Might miss some data 8

} CPU Interrupt-request line triggered by I/O device Checked by processor after each instruction } Interrupt handler receives interrupts Masked to ignore or delay some interrupts } Interrupt vector to dispatch interrupt to correct handler Context switch at start and end Based on priority Some nonmaskable Interrupt chaining if more than one device at same interrupt number 9

10

} Interrupt vector table is used to identify which device sent out the interrupt When multiple devices share a interrupt number, the handlers are checked one by one } Interrupt mechanism also used for exceptions Terminate process, crash system due to hardware error Page fault executes when memory access error System call executes via trap to trigger kernel to execute request } Multi-CPU systems can process interrupts concurrently If operating system designed to handle it 11

Process 1 Process 1 Process 2 Process 2 User Mode Kernel Mode System Call Handler Scheduler Interrupt Handler System Call Timer Interrupt Device Interrupt 12

} Used to avoid programmed I/O (one or few bytes at a time) for large data movement } Requires DMA controller } Bypasses CPU to transfer data directly between I/O device and memory } OS writes DMA command block into memory Source and destination addresses Read or write mode Count of bytes For each read/write: Device ready à DMA-request DMA controller complete à DMA-acknowledge When done, interrupts to signal completion 13

14

15

} I/O system calls encapsulate device behaviors in generic classes } Device-driver layer hides differences among I/O controllers from kernel } New devices talking already-implemented protocols need no extra work } Each OS has its own I/O subsystem structures and device driver frameworks } Unix ioctl() call to send arbitrary bits to a device control register and data to device data register (called escape or back door) Which device Which command The pointer to the data } Device characteristics vary in many dimensions 16

17

} Character Devices Sequential access Commands include get(), put() Examples include printer, sound board, terminal The same device may have both block and character oriented interfaces } Block Devices Commands include read, write, seek Raw I/O, direct I/O, or file-system access Raw I/O: no file system support, manage the device directly Direct I/O: with file system support but without buffering and locking Block size is from 512B to 4KB For example, disks are commonly implemented as block devices 18

} Varying enough from block and character to have own interface } Unix and Windows have socket (e.g., IP + port) interface Separates network protocol from network operation Includes select() functionality select() returns that which sockets have data to be received and which sockets are available for sending data now } Approaches vary widely 19

} Hardware clocks and timers provide three basic functions: Give the current time Give the elapsed time Set a timer to trigger operation X at time T } Some high-frequency counters do not generate interrupts, but they offers accurate measurements of time intervals 20

} Blocking I/O The execution of the application is suspended until the expected results are provided } Nonblocking I/O Nonblocking call returns quickly, with a return value that indicates how many bytes were transferred } Asynchronous I/O Asynchronous call returns immediately, without waiting for the I/O to complete The completion of the I/O at some future time is communicated to the application 21

This information is used for the disk I/O scheduling in Chapter 12 22

} Buffering store data in memory while transferring between devices To cope with device speed mismatch To cope with device transfer size mismatch To maintain copy semantics The data might be modified after the copy is issued and before it completes } Double buffering two copies of the data It decouples the producer of data from the consumer, thus relaxing timing requirements between them Producer à Consumer à 23

} 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 } 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, holds a copy on faster storage of an item that resides elsewhere. } Caching and buffering are distinct functions, but sometimes a region of memory can be used for both purposes 24

} A spool is a buffer that holds multiple outputs for a device, such as a printer, that cannot accept interleaved data streams 25

} OS can recover from disk read failures, device unavailable, transient write failures Retry a read or write, for example Some systems more advanced SCSI An additional sense code that states the category of failure } Return an error number or code when I/O request fails } I/O Protection: User process may accidentally or purposefully attempt to disrupt normal operation via illegal I/O instructions All I/O instructions defined to be privileged I/O must be performed via system calls 26

27

} Set system call table At /arch/x86/kernel/ for older version, or at /arch/x86/syscalls for new version Use assembly to map the name of a new system call to a number and the vector } Set header file to define the system call number For example, at unistd.h Let the C code know the mapping information of the system call } Define system call prototype For example, at syscall.h } Implement the system call } Modify Makefile to compile the kernel with the changes 28

} Consider reading a file from disk for a process: Determine which device is holding the file Mount table à which device (major number, minor number) Translate name to device representation File system à where is the file in the disk Physically read data from disk into buffer Make data available to requesting process Return control to process } Major number Each device driver is identified by a unique major number } Minor number This uniquely identifies a particular instance of a device 29

30

} I/O is 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 } Improving I/O performance Reduce number of context switches Reduce data copying Reduce interrupts by using large transfers, smart controllers, polling Use DMA Use smarter hardware devices Balance CPU, memory, bus, and I/O performance for highest throughput Move user-mode processes/daemons to kernel threads 31

32