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

Slides:



Advertisements
Similar presentations
I/O Systems & Mass-Storage Systems
Advertisements

Slide 5-1 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 5 Device Management.
Device Management.
Slide 5-1 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 5 Device Management.
Slide 4-1 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 4 Computer Organization.
Slide 3-1 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 3 3 Operating System Organization.
CS4315A. Berrached:CMS:UHD1 Operating Systems and Computer Organization Chapter 4.
Chapter 13: I/O Systems Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 13: I/O Systems I/O Hardware Application I/O Interface.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 13: I/O Systems I/O Hardware Application I/O Interface Kernel I/O Subsystem.
Chapter 13: I/O Systems Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Jan 2, 2005 Chapter 13: I/O Systems I/O Hardware.
5 Device Management.
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)
04/16/2010CSCI 315 Operating Systems Design1 I/O Systems Notice: The slides for this lecture have been largely based on those accompanying an earlier edition.
Slide 5-1 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5.
I/O Systems CS 3100 I/O Hardware1. I/O Hardware Incredible variety of I/O devices Common concepts ◦Port ◦Bus (daisy chain or shared direct access) ◦Controller.
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
1 Today I/O Systems Storage. 2 I/O Devices Many different kinds of I/O devices Software that controls them: device drivers.
I/O Systems CSCI 444/544 Operating Systems Fall 2008.
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
Copyright ©: Nahrstedt, Angrave, Abdelzaher
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.
1 Input/Output. 2 Principles of I/O Hardware Some typical device, network, and data base rates.
Disk Access. DISK STRUCTURE Sector: Smallest unit of data transfer from/to disk; 512B 2/4/8 adjacent sectors transferred together: Blocks Read/write heads.
1 Computer System Overview Chapter 1. 2 n An Operating System makes the computing power available to users by controlling the hardware n Let us review.
Segmentation & O/S Input/Output Chapter 4 & 5 Tuesday, April 3, 2007.
NETW 3005 I/O Systems. Reading For this lecture, you should have read Chapter 13 (Sections 1-4, 7). NETW3005 (Operating Systems) Lecture 10 - I/O Systems2.
Hardware Definitions –Port: Point of connection –Bus: Interface Daisy Chain (A=>B=>…=>X) Shared Direct Device Access –Controller: Device Electronics –Registers:
Chapter 13: I/O Systems Silberschatz, Galvin and Gagne ©2005 AE4B33OSS Chapter 13: I/O Systems I/O Hardware Application I/O Interface Kernel I/O.
I/O Systems I/O Hardware Application I/O Interface
Windows Operating System Internals - by David A. Solomon and Mark E. Russinovich with Andreas Polze Unit OS6: Device Management 6.1. Principles of I/O.
Contact Information Office: 225 Neville Hall Office Hours: Monday and Wednesday 12:00-1:00 and by appointment.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Principles of I/0 hardware.
1 Comp 104: Operating Systems Concepts Devices. 2 Today Devices –Introduction –Handling I/O Device handling Buffering and caching.
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.
Slide 5-1 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 5 Device Management.
Slide 5-1 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 13: I/O Systems I/O Hardware Application I/O Interface Kernel I/O Subsystem.
Slide 4-1 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 4 4 Computer Organization.
Chapter 13: I/O Systems Silberschatz, Galvin and Gagne ©2005 Operating System Principles Chapter 13: I/O Systems I/O Hardware Application I/O Interface.
Chapter 13 – I/O Systems (Pgs ). Devices  Two conflicting properties A. Growing uniformity in interfaces (both h/w and s/w): e.g., USB, TWAIN.
Slide 5-1 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5.
XE33OSA Chapter 13: I/O Systems. 13.2XE33OSA Silberschatz, Galvin and Gagne ©2005 Chapter 13: I/O Systems I/O Hardware Application I/O Interface Kernel.
Silberschatz, Galvin and Gagne ©2009 Edited by Khoury, 2015 Operating System Concepts – 9 th Edition, Chapter 13: I/O Systems.
1 Lecture 1: Computer System Structures We go over the aspects of computer architecture relevant to OS design  overview  input and output (I/O) organization.
Chapter 13: I/O Systems Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 13: I/O Systems Overview I/O Hardware Application.
© 2004, D. J. Foreman 1 Device Mgmt. © 2004, D. J. Foreman 2 Device Management Organization  Multiple layers ■ Application ■ Operating System ■ Driver.
© 2004, D. J. Foreman 1 Device Mgmt. © 2004, D. J. Foreman 2 Device Management Organization  Multiple layers ■ Application ■ Operating System ■ Driver.
Chapter 13: I/O Systems Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Jan 2, 2005 I/O through system calls Protection.
CS4315A. Berrached:CMS:UHD1 Operating Systems and Computer Organization Chapter 4.
Computer Organization (Review of Prerequisite Material)
Silberschatz, Galvin, and Gagne  Applied Operating System Concepts Module 12: I/O Systems I/O hardwared Application I/O Interface Kernel I/O.
Slide 4-1 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 4.
CSCI/CMPE 4334 Operating Systems Review: Exam 1 1.
Introduction to Operating Systems Concepts
Chapter 13: I/O Systems.
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.
CSCI 315 Operating Systems Design
I/O Systems I/O Hardware Application I/O Interface
Operating System Concepts
CS703 - Advanced Operating Systems
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
Outline Device Management Device Manager Design Buffering
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
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:

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

Slide 5-2 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 Announcements Homework Set #1 due Thursday 11 am, see moodle copyright issues with lectures Read chapters 4 and 5 –skip sections 4.7, 4.8 –skip Sections 5.4, 5.5 for now

Slide 5-3 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 Determining When I/O is Complete CPU Device Interrupt Pending CPU incorporates an “interrupt pending” flag When device.busy  FALSE, interrupt pending flag is set Hardware “tells” OS that the interrupt occurred Interrupt handler part of the OS makes process ready to run

Slide 5-4 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 Control Unit with Interrupt (Hardware) PC = ; IR = memory[PC]; haltFlag = CLEAR; while(haltFlag not SET) { execute(IR); PC = PC + sizeof(INSTRUCT); IR = memory[PC]; if(InterruptRequest) { memory[0] = PC; PC = memory[1] }; memory[1] contains the address of the interrupt handler could be a trap instr.

Slide 5-5 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 Examples of Exceptions in Pentium Systems ClassCauseAsync/ Sync Return behavior TrapIntentional exception Syncalways returns to next instruction FaultPotentially recoverable error Syncmight return to current instruction Abortnonrecover- able error Syncnever returns Interruptsignal from I/O device Asyncalways returns to next instruction

Slide 5-6 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 The Trap Instruction Operation S Mode Trusted Code trap UserSupervisor Branch Table 2 31 a trap is a “software” interrupt hardware interrupts behave similarly, an interrupt gives an offset into interrupt vector table

Slide 5-7 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 Examples of Exceptions in Pentium Systems Exception Number DescriptionException Class 0Divide errorfault 13General protection fault fault 14Page faultfault 18machine checkabort OS-definedInterrupt or trap 128System callTrap OS-definedInterrupt or trap Exception Table, also called Branch Table or Jump Table or Interrupt Vector OS assigns maskable interrupts non- maskable

Slide 5-8 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 Maskable Interrupts Maskable interrupts can be turned off by CPU before execution of critical instruction sequences –are used by device controllers to talk with CPU Nonmaskable interrupts/exceptions is reserved for events such as unrecoverable memory errors and cannot be turned off by the CPU Can have multiple interrupt priority levels –high-priority interrupts can preempt execution of a low- priority interrupt

Slide 5-9 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 Disabling Maskable Interrupts saveProcessorState() { for(i=0; i<NumberOfRegisters; i++) memory[K+i] = R[i]; for(i=0; i<NumberOfStatusRegisters; i++) memory[K+NumberOfRegisters+i] = StatusRegister[i]; } PC = ; IR = memory[PC]; haltFlag = CLEAR; while(haltFlag not SET) { execute(IR); PC = PC + sizeof(INSTRUCT); IR = memory[PC]; if(InterruptRequest && InterruptEnabled) { disableInterupts(); memory[0] = PC; PC = memory[1] }; have to reenable interrupts after done

Slide 5-10 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 Classes of System Calls Invoked by trap end, abort load, execute create, terminate get attributes, set wait for time wait event, signal event allocate memory, free Process control Comm- unications File Management Device Management Information Management system call interface request device, release read, write, reposition get attributes, set logically attach or detach devices create connection, delete send messages, receive transfer status info attach remote devices, detach create, delete open, close read, write, reposition get attributes, set get time/date, set get system data, set get process, file, or device attributes, set Note Similarity

Slide 5-11 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 The Device Driver Interface Device Interface … write(…); … Terminal Driver Terminal Driver Printer Driver Printer Driver Disk Driver Disk Driver Terminal Controller Terminal Controller Printer Controller Printer Controller Disk Controller Disk Controller

Slide 5-12 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 Device Management Organization Application Process Application Process File Manager File Manager Device Controller Command Status Data Hardware Interface System Interface Device-Independent Device-Dependent e.g. write() Device Manager or I/O Subsystem drivers

Slide 5-13 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 Device System Call Interface Functions available to application programs Abstract all devices (and files) to a few interfaces Make interfaces as similar as possible –Block vs character –Sequential vs direct/random access –Blocking versus Non-Blocking I/O blocking system call: process put on wait queue until I/O completes non-blocking system call: returns immediately with partial number of bytes transferred, e.g. keyboard, mouse, network sockets –Synchronous versus asynchronous asynchronous returns immediately, but at some later time, the full number of bytes requested is transferred Device driver implements functions (one entry point per API function)

Slide 5-14 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 Example: BSD UNIX Driver open Prepare dev for operation close No longer using the device ioctl Character dev specific info read Character dev input op write Character dev output op strategy Block dev input/output ops select Character dev check for data stop Discontinue a stream output op

Slide 5-15 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 Device Independent Function Call func i (…) Trap Table dev_func_i(devID, …) { // Processing common to all devices … switch(devID) { case dev0:dev0_func_i(…); break; case dev1:dev1_func_i(…); break; … case devM:devM_func_i(…); break; }; // Processing common to all devices … }

Slide 5-16 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 Overlapping the Operation of a Device and the CPU Variable x Register Data on device... read(dev_I, “%d”, x); y = f(x)... Device dev_I Memory CPU... startRead(dev_I, “%d”, x);... While(stillReading()) ; y = f(x)...

Slide 5-17 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 Overlapping CPU-Controller Operations in a Process App I/O Ctlr t1t1 t2t2 t3t3 t4t4 t5t5 t6t6 t7t7 t8t8 t9t9 could be non-blocking or asynchronous system call

Slide 5-18 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 Overlapping Processing and I/O App 1 App 2 I/O Ctlr t1t1 t2t2 t3t3 t4t4 App1 makes a blocking or synchronous system call

Slide 5-19 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 Device Manager I/O Strategies Underneath the blocking/non-blocking synchronous/asynchronous system call API, OS can implement several strategies for I/O with devices –direct I/O with polling –direct I/O with interrupts –DMA with interrupts

Slide 5-20 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 Polling I/O Read Operation read(device, …); Data Device Controller Command Status Data read driver write driver Hardware Interface System Interface

Slide 5-21 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 Interrupt-driven I/O Operation read(device, …); Data Device Controller Command Status Data read driver write driver Hardware Interface System Interface Device Status Table Device Handler Device Handler Interrupt Handler Interrupt Handler 6 7 8a 8b 9

Slide 5-22 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 Driver-Kernel Interface Drivers are distinct from main part of kernel Kernel makes calls on specific functions, drivers implement them Drivers use kernel functions for: –Device allocation –Resource (e.g., memory) allocation –Scheduling –etc. (varies from OS to OS)

Slide 5-23 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 DMA with Interrupts Example CPU Memory DMA/bus/interrupt Controller Disk Controller I/O Bus CPU/Memory Bus 1. device driver told to transfer bytes from disk to memory 2. dev driver informs disk controller 3. disk controller initiates DMA 4. disk controller sends each byte to DMA controller 5. DMA sends each byte to memory 6. DMA interrupts CPU when done

Slide 5-24 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 Handling Interrupts int read(…) { // Prepare for I/O save_state(J); outdev# // Done (no return) } Device driver J Device Controller Interrupt Handler void dev_handler(…) { get_state(J); //Cleanup after op signal(dev[j]); return_from_sys_call(); } Device interrupt handler J J Device status table

Slide 5-25 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 Handling Interrupts(2) int read(…) { … outdev# // Return after interrupt wait(dev[J}); return_from_sys_call(); } Device driver J Device Controller Interrupt Handler void dev_handler(…) { //Cleanup after op signal(dev[j]); } Device interrupt handler J

Slide 5-26 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5

Slide 5-27 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 Reconfigurable Device Drivers Other Kernel services Other Kernel services Entry Points for Device j open(){…} read(){…} etc. System call interface Driver for Device j

Slide 5-28 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 The Pure Cycle Water Company Water CompanyCustomer Office Water Consumers Water Producer Delivering Water Returning the Empties

Slide 5-29 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 Hardware Buffering Process Controller Data Device Process Controller B Device A Process Controller B Device A Unbuffered Process reads b i-1 Controller reads b i Process reads b i Controller reads b i+1

Slide 5-30 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 Double Buffering in the Driver Process Controller B Device A Process Controller B Device A BABA Hardware Driver

Slide 5-31 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 Circular Buffering From data producer To data consumer Buffer i Buffer j

Slide 5-32 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 A Generic Communications Device Generic Controller Generic Controller Local Device Local Device Communications Controller Communications Controller Device Cabling connecting the controller to the device Printer Modem Network Bus

Slide 5-33 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 Rotating Media Track (Cylinder) Sector (a) Multi-surface Disk(b) Disk Surface(b) Cylinders Cylinder (set of tracks)

Slide 5-34 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 Storage Device Magnetic Disk (SCSI) Controller Driver Get disk description Set SCSI parms read/write ops Interrupt hander SCSI API commands bits per byte etc. Device Driver API

Slide 5-35 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 Compute vs I/O Bound Compute-bound I/O-bound Time

Slide 5-36 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 Disk Optimizations Transfer Time: Time to copy bits from disk surface to memory Disk latency time: Rotational delay waiting for proper sector to rotate under R/W head Disk seek time: Delay while R/W head moves to the destination track/cylinder Access Time = seek + latency + transfer

Slide 5-37 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 Optimizing Seek Time Multiprogramming on I/O-bound programs => set of processes waiting for disk Seek time dominates access time => minimize seek time across the set Tracks 0:99; Head at track 75, requests for 23, 87, 36, 93, 66 FCFS: = 251 steps

Slide 5-38 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 Optimizing Seek Time (cont) Requests = 23, 87, 36, 93, 66 SSTF: (75), 66, 87, 93, 36, 23 – = 107 steps Scan: (75), 87, 93, 99, 66, 36, 23 – = 100 steps Look: (75), 87, 93, 66, 36, 23 – = 87 steps

Slide 5-39 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 Optimizing Seek Time (cont) Requests = 23, 87, 36, 93, 66 Circular Scan: (75), 87, 93, 99, 23, 36, 66 – home = 90 + home Circular Look: (75), 87, 93, 23, 36, 66 – home = 84 + home

Slide 5-40 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 Serial Port Serial Device Serial Device Memory CPU Printer Terminal Modem Mouse etc.

Slide 5-41 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 Serial Port RS-232 Interface 9-pin connector 4-wires bit transmit/receive... Serial Device (UART) UART API parity bits per byte etc. Device Driver Set UART parms read/write ops Interrupt hander Software on the CPU Device Driver API Bus Interface

Slide 5-42 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 Adding a Modem Serial Device Serial Device Memory CPU Modem Phone Switched Telephone Network Dialing & connecting Convert analog voice to/from digital Convert bytes to/from bit streams Transmit/receive protocol

Slide 5-43 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 Serial Communication Modem RS-232 Serial Device Device Driver Set UART parms read/write ops Interrupt hander Driver-Modem Protocol Dialing & connecting Convert analog voice to/from digital Convert bytes to/from bit streams Transmit/receive protocol

Slide 5-44 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 Comm Device Comm Device Memory CPU Modem Phone Comm Device Comm Device Memory CPU Modem Phone Switched Telephone Network Exploiting the Phone Network Logical Communication

Slide 5-45 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 Data Networks Network Device Network Device Memory CPU Network Device Network Device Memory CPU Data Network Logical Communication Technology focus includes protocols and software (more on this later … Chapter 15 and beyond...)

Slide 5-46 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 MS Disk Description

Slide 5-47 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 NT Driver Organization

Slide 5-48 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 NT Device Drivers API model is the same as for a file Extend device management by adding modules to the stream Device driver is invoked via an Interrupt Request Packet (IRP) –IRP can come from another stream module –IRP can come from the OS –Driver must respond to minimum set of IRPs See Part I of notes