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

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

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

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

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

Chapter 5 Input/Output. I/O Devices

I/O Systems. Jo, Heeseung

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

Module 11: I/O Systems

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

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

Operating Systems CMPSC 473 File System Implementation April 10, Lecture 21 Instructor: Trent Jaeger

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

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

OPERATING SYSTEMS CS136

Input / Output. Kevin Webb Swarthmore College April 12, 2018

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

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

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

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.

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

[08] IO SUBSYSTEM 1. 1

Input/Output Systems

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

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

Chapter 13: I/O Systems

Hardware OS & OS- Application interface

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

Input Output (IO) Management

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

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

ECE 341. Lecture # 19

CSE380 - Operating Systems. Communicating with Devices

I/O Management and Disk Scheduling. Chapter 11

I/O SYSTEMS. Sunu Wibirama

Operating Systems. V. Input / Output

Principles of Operating Systems CS 446/646

I/O Management Intro. Chapter 5

Ausgewählte Betriebssysteme - Mark Russinovich & David Solomon (used with permission of authors)

I/O AND DEVICE HANDLING Operating Systems Design Euiseong Seo

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

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

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

Chapter 13: I/O Systems

Input/Output Systems

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)

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

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

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

C02: Interrupts and I/O

I/O Devices. Nima Honarmand (Based on slides by Prof. Andrea Arpaci-Dusseau)

Spring 2017 :: CSE 506. Device Programming. Nima Honarmand

I/O - input/output. system components: CPU, memory, and bus -- now add I/O controllers and peripheral devices. CPU Cache

Computer Architecture CS 355 Busses & I/O System

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

Computer System Overview

Operating Systems CMPSCI 377 Spring Mark Corner University of Massachusetts Amherst

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

Input/Output Management

ECE 485/585 Microprocessor System Design

Misc. Third Generation Batch Multiprogramming. Fourth Generation Time Sharing. Last Time Evolution of OSs

EE108B Lecture 17 I/O Buses and Interfacing to CPU. Christos Kozyrakis Stanford University

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

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

Introduction. CS3026 Operating Systems Lecture 01

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

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

Chapter 13: I/O Systems

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

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

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

Module 12: I/O Systems

CSE 380 Computer Operating Systems

Common Computer-System and OS Structures

Chapter 8. A Typical collection of I/O devices. Interrupts. Processor. Cache. Memory I/O bus. I/O controller I/O I/O. Main memory.

Input/Output. 198:231 Introduction to Computer Organization Lecture 15. Instructor: Nicole Hynes

CS370 Operating Systems

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

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

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

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

Device-Functionality Progression

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

I/O Devices. I/O Management Intro. Sample Data Rates. I/O Device Handling. Categories of I/O Devices (by usage)

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

INPUT/OUTPUT ORGANIZATION

Module 12: I/O Systems

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

Slide 5-1. Device. Management. Operating Systems: A Modern Perspective, Chapter 5. Copyright 2004 Pearson Education, Inc.

I/O Management Intro. Chapter 5

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

Topic 2. System calls. 1. Basic architecture 2. Input/Output routine mechanism 3. Resident routines 4. Accessing OS services: system calls

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)

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

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

Chapter 13: I/O Systems

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

CS 111. Operating Systems Peter Reiher

CS370 Operating Systems

Transcription:

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

Last class: File System Interface Today: I/O

OS role in I/O Share the same device across different processes/users User does not see the details of how hardware works Device-independent interface to provide uniformity across devices.

I/O Peripherals 0x00 0 CPU il1 L2 Memory Bus (e.g. PC133) Main Memory dl1 0x0ff..f On-chip I/O Bus (e.g. PCI) Disk Ctrller Net. Int. Ctrller 0x100 0 0x1ff.f 0x200 0 0x2ff.f

Talk to Devices Communication Send instructions to the devices Get the results I/O Ports Dedicated I/O registers for communicating status and requests Memory-mapped I/O Map the registers into main memory Communicate requests through memory Memory-mapped data registers can be larger Think graphics device

Memory-mapped I/O Can read and write device registers just like normal memory. However, user programs are NOT typically allowed to do these reads/writes. The OS has to manage/control these devices. The addresses to these devices may not need to go through address translation since OS is the one accessing them and protection does not need to be enforced, and there is no swapping/paging for these addresses.

Consider a disk device 0x00 0 Memory Bus (e.g. PC133) Main Memory I/O Bus (e.g. PCI) 0x100 0 RAM 0x0ff..f Controller 0x1ff.f

Reading a sector from disk Store [Command_Reg], READ_COMMAND Store [Track_Reg], Track # Store [Sector_Reg], Sector # /* Device starts operation */ L: Load R, [Status_Reg] cmp R, 0 jeq /* Data now on memory of card */ For i = 1 to sectorsize Memtarget[i] = MemOnCard[i] You don t want to do this! Instead, block/switch to other process and let an interrupt wake you up. This is again a lot of overhead to ask the main CPU to do!

Interrupt Cycle

DMA engine to offload work of copying 0x00 0 Memory Bus (e.g. PC133) Main Memory I/O Bus (e.g. PCI) 0x100 0 DMA RAM 0x0ff..f Controller 0x1ff.f

Store [Command_Reg], READ_COMMAND Store [Track_Reg], Track # Store [Sector_Reg], Sector # Store [Memory_Address_Reg], Address Assuming an integrated DMA and disk ctrller. /* Device starts operation */ P(disk_request); /* Operation complete and data is now in required memory locations*/ Called when DMA raises interrupt after Completion of transfer ISR() { V(disk_request); }

Issues to consider What is purpose of RAM on card? To address the speed mismatch between the bit stream coming from disk and the transfer to main memory. When we program the DMA engine with address of transfer (Store [Memory_Address_Reg], Address), is Address virtual or physical? It has to be a physical address, since the addresses generated by the DMA do NOT go through the MMU (address translation). But since it is the OS programming the DMA, this is available and it is NOT a problem. You do NOT want to give this option to user programs. Also, the address needs to be pinned (cannot be evicted) in memory.

Block devices: I/O Devices usually stores information in fixed size blocks you read or write an individual block independently of others by giving it an address. E.g., disks, tapes, Character devices: delivers or accepts streams of characters Not addressable. E.g., terminals, printers, mouse, network interface.

Principles of I/O Software Provide device independence: same programs should work with different devices. uniform naming -- i.e., name shouldn't depend on the device. error handling, handle it as low as possible and only if unavoidable pass it on higher. synchronous (blocking) vs. asynchronous (interrupt driven). Even though I/O devices are usually async, sync is easier to program

Characteristics of Devices

I/O Software A layered approach: Lowest layer (device dependent): Device drivers Middle layer: Device independent OS software High level: User-level software/libraries The first 2 are part of the kernel.

Device Drivers Accept abstract requests from device-independent OS software, and service those requests. There is a device driver for each device However, the interface to all device drivers is the same. Open(), close(), read(), write(), interrupt(), ioctl(),

Semaphore request; Disk driver Open() {.} Close() { } Read() {. program the device P(request); } Interrupt() { check what caused the interrupt case disk_read: V(request); } Write() {. }

Device-independent OS Layer Device naming and protection Each device is given a (major #,minor #) present in the i-node for that device Major # identifies the driver Minor # is passed on to the driver (to handle sub-devices) Does buffering/caching Uses a device-independent block size Handles error reporting in a device-independent fashion.

Putting things together (UNIX) User calls open( /dev/tty0, w ) which is a system call. OS traverses file system to find the i-node of tty0. This should contain the (major #, minor #). Check permissions to make sure it is allowed. An entry is created in OFDT, and a handle is returned to the user. When user calls write(fd,.) subsequently, index into OFDT, get major/minor #s.

I/O and Kernel Objects

Major # Getting to the driver Open_fp; Close_fp; Read_fp; Write_fp;. Open_fp; Close_fp; Read_fp; Write_fp;. Open_fp; Close_fp; Read_fp; Write_fp;. In Memory Data Struct routine Open() { } Close() { } Read() { } Write() { }. Open() { } Close() { } Read() { } Write() { }. Driver codes supplied by h/w vendors Linked (needs kernel reboot for Installation) or dynamically loaded into Kernel.

Copy the bytes pointed to by the pointer given by user, into a kernel pinned (which is not going to be paged out) buffer. Use the above data structure, to find the relevant driver s write() routine, and call it with the pinned buffer address, and other relevant parameters. For a write, one can possibly return back to user even if the write has not propagated. On a read (for an input device), the driver would program the device, and block the activity till the interrupt.

This was a character device. In a block device, before calling the driver, check the buffer/cache that the OS is maintaining to see if the request can be satisfied before going to the driver itself. The lookup is done based on (major #, logical block id). Thus it is a unified device-independent cache across all devices.

This is all for the user referring to an I/O device (/dev/*). Note: It is not very different when the user references a normal file. In that case, we have already seen how the file system generates a request in the form of a logical block id, which is then sent to the driver where the specified file system resides (disk/cd/ )

Life Cycle of an I/O Request

Input/Output Summary The OS Manages Device Usage Communication I/O Subsystem

Next time: Protection