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

Slides:



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

I/O Management and Disk Scheduling
Chapter 6 I/O Systems.
I/O Management and Disk Scheduling
I/O Management and Disk Scheduling
CT213 – Computing system Organization
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.
Input/Output Management and Disk Scheduling
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.
Midterm Tuesday October 23 Covers Chapters 3 through 6 - Buses, Clocks, Timing, Edge Triggering, Level Triggering - Cache Memory Systems - Internal Memory.
Device Management.
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.
Input/Output. Input/Output Problems Wide variety of peripherals —Delivering different amounts of data —At different speeds —In different formats All slower.
System Calls 1.
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.
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.
Hardware Definitions –Port: Point of connection –Bus: Interface Daisy Chain (A=>B=>…=>X) Shared Direct Device Access –Controller: Device Electronics –Registers:
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.
1 Comp 104: Operating Systems Concepts Devices. 2 Today Devices –Introduction –Handling I/O Device handling Buffering and caching.
Computer Architecture Lecture10: Input/output devices Piotr Bilski.
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
1 I/O Management and Disk Scheduling Chapter Categories of I/O Devices Human readable –Used to communicate with the user –Printers –Video display.
Slide 5-1 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5.
Device Drivers CPU I/O Interface Device Driver DEVICECONTROL OPERATIONSDATA TRANSFER OPERATIONS Disk Seek to Sector, Track, Cyl. Seek Home Position.
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.
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 (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.
Slide 5-1 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 5 Device Management.
Input/Output Problems Wide variety of peripherals —Delivering different amounts of data —At different speeds —In different formats All slower than CPU.
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.
CS4315A. Berrached:CMS:UHD1 Operating Systems and Computer Organization Chapter 4.
Silberschatz, Galvin, and Gagne  Applied Operating System Concepts Module 12: I/O Systems I/O hardwared Application I/O Interface Kernel I/O.
1 Device Controller I/O units typically consist of A mechanical component: the device itself An electronic component: the device controller or adapter.
CSCI/CMPE 4334 Operating Systems Review: Exam 1 1.
Introduction to Operating Systems Concepts
Operating Systems (CS 340 D)
CSCI 315 Operating Systems Design
I/O Systems I/O Hardware Application I/O Interface
Operating System Concepts
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

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

Slide 5-3 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 Input/Output Devices Input Device Processor Output Device

Slide 5-4 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 I/O devices Each I/O device consists of a device controller and the physical device itself. Devices: - storage devices: for permanent storage (e.g. disk, tape) - communication devices: to transfer data from the computer to another machine (e.g. keyboard, a terminal display, or a serial port to a modem or a network). Devices can be character-oriented (e.g. a terminal) or block-oriented (e.g. a disk)

Slide 5-5 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 I/O Devices (cont.) Device controller: hardware that connects the device to the computer’s address and data bus: –continuously monitors and controls the operation of the device. – provides an interface to the computer: a set of components that the CPU can manipulate to perform I/O operations. Need to have a standard interface so that devices can be interchanged.

Slide 5-6 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 I/O devices Device Manager: consists of a collection of device drivers – hide the operation details of each device controller from application programmer. –provide a “common” interface to all sorts of devices. e.g. Open, close (to allocate/deallocate device), read/write, etc. Device Controller Device System Bus Device manager Application Program

Slide 5-7 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-8 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 Infrastructure and device drivers Device Manager is composed of device manager infrastructure (device independent part) and a collection of device drivers (device dependent part) Infrastructure: –exports the common device interface as system calls –Routes calls on the generic interface to specific device driver functions

Slide 5-9 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

Slide 5-10 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 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 access Device driver implements functions (one entry point per API function)

Slide 5-11 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-12 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 I/O Strategies Direct I/O with polling DMA I/O with polling Direct I/O with interrupts DMA I/O with interrupts

Slide 5-13 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 Performing a Write Operation Device driver: 1. While (device is not idle) keep checking; 2. Set command register to WRITE and set busy flag to Move address of source into address register of controller 4. Move data to be written into data registers of the controller. Device-Controller: 1. Store data from data registers into the device. 2. When operation is completed, clear busy flag and set done flag to Wait for busy flag to be cleared when busy flag becomes clear, clear done flag to 0.

Slide 5-14 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 Performing a Write Operation Device Driver: while (device.busy || device.done) ; device.data[0] = ; device.address[0] = device.command = WRITE ; this also sets busy flag while (device.busy) ; device.done = 0; return to calling process;

Slide 5-15 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 Performing a Read Operation while (device.busy || device.done) ; device.command = READ ; this also sets busy flag device.address[0] = while (device.busy) ; Move value in device.data[0] to memory or CPU register; device.done = 0; Note: Polling is used to determine status of I/O device while device operates, the CPU waits. When device is done, CPU continues with rest of program => Direct I/O with polling

Slide 5-16 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 function write function Hardware Interface System Interface

Slide 5-17 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-18 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

Slide 5-19 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

Slide 5-20 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 Interrupt Driven I/O Instead of having the CPU continuously poll status register of I/O device(s), have I/O device notify CPU when it has completed an I/O operation. –CPU initiates an I/O operation as described before –as I/O device performs the operation, CPU is switched to another process (thru the process scheduler). –When the I/O device is done, it notifies the CPU by sending it an interrupt signal. –The CPU switches control to an interrupt handler to service the interrupt. –The interrupt handler completes I/O operation and returns control to interrupted process.

Slide 5-21 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 Interrupt Driven I/O An InterruptRequest flag is incorporated in the CPU Whenever an I/O device has completed its I/O operation, it sets the InterruptRequest flag to 1. Conceptually, this can be done by connecting the done flags of all I/O controllers to the InterruptRequest flag through an OR gate. Control unit of the CPU must check the InterruptRequest flag before it starts each instruction. If flag is set, it jumps to an interrupt handler program.

Slide 5-22 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 Interrupt Driven I/O

Slide 5-23 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 Fetch-Execute Cycle with Interrupt PC = ; IR = Memory[PC] ; haltFlag = CLEAR ; Decode(IR); while (haltFlag not SET) { Execute(IR); PC = PC + InstructionSize; if (InterruptRequest) { save current PC; // (e.g. in system stack) PC = AddressOfInterruptHandler; } IR = Memory[PC] ; Decode(IR); }

Slide 5-24 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 Interrupt Handler The Interrupt Handler is a program that is part of the device manager. Each time it is called it does the following: 1. Save the state of the interrupted process: save the contents of CPU registers (all registers) and load CPU registers with its own values: Context Switch 2. Determine which I/O device caused the interrupt 3. Branch to the device driver associated with that device.

Slide 5-25 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 Interrupt Handler Interrupt_Handler { clear InterruptRequest flag; saveProcessorState();// Context Switch for (i=0; i < Number_of_devices; i++)//poll if (device[i].done == 1) goto device_driver(i); }

Slide 5-26 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 Device Driver The device driver is a program that is part of the device manager. When called, it does the following: –determine the cause of the interrupt –complete the I/O operation –clear the done flag of the device controller status register –restore the state of the interrupted process context switch –return control to interrupted process

Slide 5-27 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 Interrupt Vector How can we avoid having the interrupt handler poll all the devices to determine which one caused the interrupt? Replace the InterruptRequest flag with an interrupt vector, ie. a collection of flags, one flag for each device. Replace the OR gate with a vector of interrupt request lines one for each device. An Interrupt Vector Table: a table of pointers to device drivers : entry i of the table stores the address of device driver i. The interrupt vector table is generally stored at a fixed location in memory (e.g. first 100 locations).

Slide 5-28 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 Race Condition What if a second interrupt occurs while the first is being processed? two possibilities: 1. Disable all other interrupts while an interrupt is being processed –use an InterruptEnabled (IE) flag in CPU –provide instructions to set and clear the ( IE ) flag –Control unit must check the ( IE ) flag before processing any interrupt. if (InterruptRequest & InterruptEnabled ) { disableInterrupts(); save current PC and other CPU regs; PC = address of interrupt handler; }

Slide 5-29 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 Race Condition 2. Enable other interrupts while an interrupt is being processed –Must use system stack to save PC and state of the interrupted process. –Must use a priority scheme. –Part of the interrupt handler routine should not be interrupted. Most CPUs have two types of interrupts: –maskable interrupts: can be interrupted –un-maskable interrupts: can not be interrupted

Slide 5-30 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 Performing a Read Operation Read(device_i, "%d", x) CPU is executing some process (say process A) Process A makes a request for a read operation to device i. This is done thru a system call to the OS The device manager of the OS check validity of system call and if valid, invokes the device driver of device i. The device driver queries the control status register (CSR) of device i to determine whether the device is idle. If the device is busy, the driver waits for it to become idle. Device driver may also have a queue of waiting I/O requests.

Slide 5-31 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 Performing a Read Operation (cont.) The driver stores a READ command into the controller’s Command register ==> device Busy bit set to 1. The CPU is switched to another process B while the I/O operation is being processed (device driver invokes CPU scheduler) Eventually the device completes the READ operation and raises an interrupt to the CPU The CPU is switched from process B to the interrupt handler.

Slide 5-32 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 Performing a Read Operation (cont.) The interrupt handler determines which device caused the interrupt and calls the device driver of device_i. The device driver determines what needs to be done and copies the contents of the controller’s data register(s) into the process space of process A (how does the device driver know which process?) when the read operation is done, the device driver clears the done flag of the device controller and returns control to the interrupted process (i.e. process B)

Slide 5-33 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 Device Status Table While an I/O operation is being done, the CPU may be switched to some other process (other than the one that requested the I/O operation) At any point of time, there may be several I/O requests pending by various processes When a device driver is called to finish an I/O operation, how does it know to which process the I/O operation belongs? Device status table: a table containing information about each I/O device.

Slide 5-34 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 Device Status Table (cont.) Contains an entry for each I/O device. Each entry contains such information as: –device type, address, state (idle, busy, not functioning, etc.) –if device is busy: the type of operation being performed by that device the process ID of the process that issued the operation for some devices: a queue of waiting requests for that device

Slide 5-35 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 Performing Read Operation CPU is executing some process (say process A) Process A makes a request for an read operation to device i. This is done thru a system call to the OS The device manager of the OS, invokes the device driver of device i. The device driver queries the CSR of device i to determine whether device i is idle. If the device is busy, the driver waits for it to become idle (or queues process if there is a queue). Else if the device is idle: If the device is idle: The driver stores a read command into the controller’s Command register ==> device Busy bit set to 1.

Slide 5-36 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 Performing Read Operation (cont.) The driver saves information regarding the I/O operation in the device status table. The status of process A is changed from running to blocked The device driver invokes the CPU scheduler, which switches the CPU to another process B Eventually the device completes the operation and interrupts the CPU The CPU is switched to the interrupt handler Interrupt handler determine which device caused the interrupt and calls the device driver of device i. The device driver retrieves information about the I/O operation on device i from the device status table ==> process A issued I/O operation

Slide 5-37 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 Performing Read Operation (cont.) The device driver copies the contents of the controller’s data register(s) into the process space of process A. Process A status should be changed from blocked to ready. If there is a queue of requests for device_I, dispatch next request. the device driver returns control to the interrupted process (i.e. process B).

Slide 5-38 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-39 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-40 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-41 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-42 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-43 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-44 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-45 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-46 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-47 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-48 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 I/O Buffering A buffer is a memory area used to store data while it is being transferred between two devices or between a device and an application. Used to reduce the effects of speed mismatch between I/O device and CPU or among I/O devices. Generally used to allow more overlap between producer and consumer ==> more overlap between the CPU and I/O devices.

Slide 5-49 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-50 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-51 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-52 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-53 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-54 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-55 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-56 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-57 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-58 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-59 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-60 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-61 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 –Subject to starvation Scan: (75), 87, 93, 99, 66, 36, 23 – = 100 steps Look: (75), 87, 93, 66, 36, 23 – = 87 steps

Slide 5-62 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-63 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 MS Disk Description

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

Slide 5-65 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