Input/Output Devices ENCE 360

Slides:



Advertisements
Similar presentations
Input/Output Management and Disk Scheduling
Advertisements

Operating Systems Input/Output Devices (Ch , 12.7; , 13.7)
Disk Drivers May 10, 2000 Instructor: Gary Kimura.
I/O Hardware n Incredible variety of I/O devices n Common concepts: – Port – connection point to the computer – Bus (daisy chain or shared direct access)
Slide 5-1 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5.
Device Management.
1 Input/Output Chapter 3 TOPICS Principles of I/O hardware Principles of I/O software I/O software layers Disks Clocks Reference: Operating Systems Design.
1 Today I/O Systems Storage. 2 I/O Devices Many different kinds of I/O devices Software that controls them: device drivers.
Operating Systems Input/Output Devices (Ch 5: )
Operating Systems Concepts 1. A Computer Model An operating system has to deal with the fact that a computer is made up of a CPU, random access memory.
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
I/O Tanenbaum, ch. 5 p. 329 – 427 Silberschatz, ch. 13 p
Device Management. Serial Port Serial Device Serial Device Memory CPU Printer Terminal Modem Mouse etc.
Chapter 3.1:Operating Systems Concepts 1. A Computer Model An operating system has to deal with the fact that a computer is made up of a CPU, random access.
Device Management. So far… We have covered CPU and memory management Computing is not interesting without I/Os Device management: the OS component that.
1 I/O Management and Disk Scheduling Chapter Categories of I/O Devices Human readable Used to communicate with the user Printers Video display terminals.
Cpr E 308 Input/Output Recall: OS must abstract out all the details of specific I/O devices Today –Block and Character Devices –Hardware Issues – Programmed.
Sistem Operasi IKH311 Masukan Luaran (Input/Output)
Slide 5-1 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5.
Chapter 13: I/O Systems. 13.2/34 Chapter 13: I/O Systems I/O Hardware Application I/O Interface Kernel I/O Subsystem Transforming I/O Requests to Hardware.
Lecture 3 Page 1 CS 111 Online Disk Drives An especially important and complex form of I/O device Still the primary method of providing stable storage.
Chapter 5 Input/Output 5.1 Principles of I/O hardware
© 2004, D. J. Foreman 1 Device Mgmt. © 2004, D. J. Foreman 2 Device Management Organization  Multiple layers ■ Application ■ Operating System ■ Driver.
Device Management Mark Stanovich Operating Systems COP 4610.
Silberschatz, Galvin, and Gagne  Applied Operating System Concepts Module 12: I/O Systems I/O hardwared Application I/O Interface Kernel I/O.
I/O Software CS 537 – Introduction to Operating Systems.
1 Device Controller I/O units typically consist of A mechanical component: the device itself An electronic component: the device controller or adapter.
Part IVI/O Systems Chapter 13: I/O Systems. I/O Hardware a typical PCI bus structure 2.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Operating Systems Overview: Using Hardware.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 10: Mass-Storage Systems.
Magnetic Disks Have cylinders, sectors platters, tracks, heads virtual and real disk blocks (x cylinders, y heads, z sectors per track) Relatively slow,
1 Chapter 11 I/O Management and Disk Scheduling Patricia Roy Manatee Community College, Venice, FL ©2008, Prentice Hall Operating Systems: Internals and.
Introduction to Operating Systems Concepts
Chapter 10: Mass-Storage Systems
Operating System (013022) Dr. H. Iwidat
Module 12: I/O Systems I/O hardware Application I/O Interface
Chapter 13: I/O Systems Modified by Dr. Neerja Mhaskar for CS 3SH3.
Sarah Diesburg Operating Systems CS 3430
Multiple Platters.
I/O System Chapter 5 Designed by .VAS.
Operating Systems (CS 340 D)
Operating Systems Disk Scheduling A. Frank - P. Weisberg.
I/O Resource Management: Software
I/O system.
CS 286 Computer Organization and Architecture
Computer Architecture
CSCI 315 Operating Systems Design
GEOMATIKA UNIVERSITY COLLEGE CHAPTER 2 OPERATING SYSTEM PRINCIPLES
Operating Systems Chapter 5: Input/Output Management
Operating System Concepts
13: I/O Systems I/O hardwared Application I/O Interface
CS703 - Advanced Operating Systems
Direct Memory Access Disk and Network transfers: awkward timing:
Outline Module 1 and 2 dealt with processes, scheduling and synchronization Next two modules will deal with memory and storage Processes require data to.
Chapter 5: I/O Systems.
Persistence: hard disk drive
Persistence: I/O devices
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
Outline Device Management Device Manager Design Buffering
Linux Block I/O Layer Chris Gill, Brian Kocoloski
CSE451 File System Introduction and Disk Drivers Autumn 2002
Device Mgmt © 2004, D. J. Foreman.
Device Mgmt © 2004, D. J. Foreman.
Chapter 13: I/O Systems.
Module 12: I/O Systems I/O hardwared Application I/O Interface
Andy Wang Operating Systems COP 4610 / CGS 5765
Chapter 5 Input/Output Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved
Chapter 13: I/O Systems “The two main jobs of a computer are I/O and [CPU] processing. In many cases, the main job is I/O, and the [CPU] processing is.
Presentation transcript:

Input/Output Devices ENCE 360 Operating Systems Input/Output Devices ENCE 360

Need for Input and Output An OS clearly needs input How else can it know what services are required? An OS clearly provides output How else are users/clients supposed to benefit from the services? THE CRUX: HOW TO INTEGRATE I/O INTO OPERATING SYSTEMS? How should I/O be integrated into OS? What are the general mechanisms? How can we make them efficient?

MODERN OPERATING SYSTEMS (MOS) Outline Introduction (done) Device Controllers (next) Device Software Hard Disks Chapter 5 MODERN OPERATING SYSTEMS (MOS) By Andrew Tanenbaum Chapter 36, 37 OPERATING SYSTEMS: THREE EASY PIECES  By Arpaci-Dusseau and Arpaci-Dusseau

Prototypical System Architecture Fast, so must be short. Also $$ Devices that demand high perf generally closer to CPU OS must deal with all devices! Longer, so slower. Need many devices

Hint: remember, devices can be slow! Canonical Device Internals can be simple (e.g., USB controller) to complex (e.g., RAID controller) For OS, device is interface - like API of 3rd party system/library! Canonical Protocol while (STATUS == BUSY) ; // wait until device is not busy write data to DATA register ; // device may need to service request write command to COMMAND register ; // starts device to execute command ; // wait until device is done See any problems? Hint: remember, devices can be slow!

Canonical Device Canonical Protocol THE CRUX: Internals can be simple (e.g., USB controller) to complex (e.g., RAID controller) For OS, device is interface - like API of 3rd party system/library! Canonical Protocol while (STATUS == BUSY) ; // wait until device is not busy write data to DATA register ; // device may need to service request write command to COMMAND register ; // starts device to execute command ; // wait until device is done THE CRUX: HOW TO AVOID THE COST OF POLLING? How can OS check device status without frequent polling?

Solution – the Interrupt (Again) Polling Instead, CPU switches to new process Device raises interrupt when done Invokes interrupt handler Interrupt

Copying Data? Ho, Hum CPU copying data (write and read) rather trivial Process 1 wants to write data to disk CPU copies data to device CPU copying data (write and read) rather trivial Could be better spent on other tasks! THE CRUX: HOW TO LOWER DEVICE OVERHEADS? How can OS offload work so CPU can be more efficient?

Solution – Direct Memory Access (DMA) CPU 1 2 3 4 CPU provides DMA address Device performs direct transfer to memory Device interrupts processor Processor accesses device data from memory

The Benefits of DMA Process 1 wants to write data to disk CPU copies data to device Device copies data from mem CPU can run another process

Outline Introduction (done) Device Controllers (done) Device Software (next) Hard Disks

HOW TO BUILD DEVICE-NEUTRAL OS? Integration Devices interfaces are very specific Even for functionally similar devices! e.g., SCSI disk vs. IDE disk vs. USB thumb drive … Not to mention functionally different devices! e.g., keyboard vs. disk vs. network card … Want system to be (mostly) oblivious to differences THE CRUX: HOW TO BUILD DEVICE-NEUTRAL OS? How to hide details of device interactions from OS interactions?

Solution – Abstraction Hardware Application oblivious to file system details File system oblivious layer specific details Device layer oblivious device specific details Device driver knows specifics of device hardware 70% of Linux is device driver code!

Generic Device Types Hardware block - access is independent of previous e.g., hard disk stream - access is serial e.g., keyboard, network other (e.g., timer/clock (just generate interrupts))

Interrupt Handler (1 of 2) Hardware (top) Interrupt Handler (bottom) Interrupts handled by device in two parts Short at first/top (generic) Longer next/bottom (device specific) (Next slide)

Interrupt Handler (2 of 2) First part minimal amount of work Defer rest until later Effectively, queue up rest Re-enable interrupts Linux: “top-half” handler Second part does most of work Run device-specific code Windows: “deferred procedure call” Linux: “bottom-half” handler When handling interrupt, other interrupts disabled Incoming ones may be lost So, make as small as possible Solution  Split into two pieces Device Driver Interrupt Handler Hardware request response top bottom

I/O System Summary I/O request I/O response User Level Library Make I/O call, format request and response Device Independent Software Handle naming, protection, blocking, buffering, allocation Device Drivers Setup device registers for request, check status upon response Interrupt Handlers Respond to interrupt when device completes I/O top bottom Hardware Perform I/O operation

Outline Introduction (done) Device Controllers (done) Device Software (done) Hard Disks (next)

The quick brown fox jumped over the lazy dogs Hard Drive Overview Hard Disk File ??? The quick brown fox jumped over the lazy dogs Hard disk has series of platters How do bytes get arranged on disk?

Reading/Writing Disk Blocks Disk with 1 track Time to read/write block: Seek time – move arm to position Rotation time – spin disk to right block Transfer time – data on/off disk Disk with 3 tracks

Organizing Disk Block Requests 21 2 Rotation fast Arm movement relatively slower  Seek time dominates Because matters so much, OS often organizes requests for efficiency  But how? So, if 2 and 21, then which next?

First-Come First-Served (FCFS) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 x Time Service requests in order that they arrive Total time: 14+13+2+6+3+12+3=53 Little done to optimize How can we make more efficient?

Shortest Seek First (SSF) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 x Time Service request closest to read arm Total time: 1+2+6+9+3+2 = 23 What might happen that is bad? Hint: something similar happened with scheduling

Shortest Seek First (SSF) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 x Time Service request closest to read arm Total time: 1+2+6+9+3+2 = 23 What might happen that is bad? Continual request near arm  starvation!

Elevator (SCAN) Total time: 1+2+6+3+2+17 = 31 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 x Time Total time: 1+2+6+3+2+17 = 31 Usually, a little worse average seek time than SSTF But more fair, avoids starvation Alternate C-SCAN has less variance Note, seek getting faster, rotational not Someday, change algorithms

State of the Art – a Mixed Bag Disks evolving (e.g., rotation + seek converging), so OS may not always know best Instead, issue cluster of requests that are likely to be best Send to disk and let disk handle Linux – no one-size fits all (sys admins tune) Complete Fair Queueing (CFQ) – queue per processes, so fair but can optimize within process Default for many systems Deadline – optimize queries (better perf), but hard limit on latency to avoid starvation Noop – no-sorting of requests at all (good for SSD. Why?)

Outline Introduction (done) Device Controllers (done) Device Software (done) Hard Disks (done)