Input/Output. Chapter 5: I/O Systems. How fast is I/O hardware? Device controllers. Memory-mapped I/O. How is memory-mapped I/O done?

Similar documents
Chap. 3. Input/Output

I/O Hardwares. Some typical device, network, and data base rates

Input/Output. Today. Next. Principles of I/O hardware & software I/O software layers Secondary storage. File systems

I/O Devices. Chapter 5 Input/Output. Memory-Mapped I/O (2) Memory-Mapped I/O (1) Interrupts Revisited. Direct Memory Access (DMA) 11/26/2013

Input/Output. Today. Next. ! Principles of I/O hardware & software! I/O software layers! Secondary storage. ! File systems

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

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

I/O, Disks, and RAID Yi Shi Fall Xi an Jiaotong University

CSE 380 Computer Operating Systems

CSE 153 Design of Operating Systems Fall 2018

Introduction Disks RAID Tertiary storage. Mass Storage. CMSC 420, York College. November 21, 2006

CSE380 - Operating Systems. Communicating with Devices

CSE 153 Design of Operating Systems

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

Chapter 13: Mass-Storage Systems. Disk Scheduling. Disk Scheduling (Cont.) Disk Structure FCFS. Moving-Head Disk Mechanism

Chapter 13: Mass-Storage Systems. Disk Structure

Chapter 5 Input/Output. I/O Devices

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

Chapter 11. I/O Management and Disk Scheduling

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

CS3600 SYSTEMS AND NETWORKS

Disk Scheduling. Chapter 14 Based on the slides supporting the text and B.Ramamurthy s slides from Spring 2001

COS 318: Operating Systems. Storage Devices. Vivek Pai Computer Science Department Princeton University

Chapter 10: Mass-Storage Systems

Module 13: Secondary-Storage Structure

Chapter 14: Mass-Storage Systems. Disk Structure

I/O & Storage. Jin-Soo Kim ( Computer Systems Laboratory Sungkyunkwan University

OPERATING SYSTEMS CS136

Disk Scheduling. Based on the slides supporting the text

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

Ref: Chap 12. Secondary Storage and I/O Systems. Applied Operating System Concepts 12.1

V. Mass Storage Systems

UNIT 4 Device Management

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

Chapter 10: Mass-Storage Systems. Operating System Concepts 9 th Edition

Operating Systems, Fall

u Covered: l Management of CPU & concurrency l Management of main memory & virtual memory u Currently --- Management of I/O devices

Mass-Storage Structure

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

Operating Systems 2010/2011

OPERATING SYSTEMS CS3502 Spring Input/Output System Chapter 9

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

Lecture 9. I/O Management and Disk Scheduling Algorithms

Chapter 10: Mass-Storage Systems

COS 318: Operating Systems. Storage Devices. Kai Li Computer Science Department Princeton University

OPERATING SYSTEMS CS3502 Spring Input/Output System Chapter 9

CSE325 Principles of Operating Systems. Mass-Storage Systems. David P. Duggan. April 19, 2011

Mass-Storage. ICS332 - Fall 2017 Operating Systems. Henri Casanova

COS 318: Operating Systems. Storage Devices. Jaswinder Pal Singh Computer Science Department Princeton University

CS420: Operating Systems. Mass Storage Structure

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

Storage. CS 3410 Computer System Organization & Programming

CHAPTER 12: MASS-STORAGE SYSTEMS (A) By I-Chen Lin Textbook: Operating System Concepts 9th Ed.

CSCI-GA Operating Systems. I/O : Disk Scheduling and RAID. Hubertus Franke

File. File System Implementation. Operations. Permissions and Data Layout. Storing and Accessing File Data. Opening a File

I/O Device Controllers. I/O Systems. I/O Ports & Memory-Mapped I/O. Direct Memory Access (DMA) Operating Systems 10/20/2010. CSC 256/456 Fall

Chapter 12: Mass-Storage Systems. Operating System Concepts 8 th Edition,

I/O Systems and Storage Devices

Chapter 12: Mass-Storage

Chapter 11 I/O Management and Disk Scheduling

Chapter 5 Input/Output

CS 471 Operating Systems. Yue Cheng. George Mason University Fall 2017

Secondary storage. CS 537 Lecture 11 Secondary Storage. Disk trends. Another trip down memory lane

STORAGE SYSTEMS. Operating Systems 2015 Spring by Euiseong Seo

I/O Management and Disk Scheduling. Chapter 11

2. Which of the following resources is not one which can result in deadlocking processes? a. a disk file b. a semaphore c. the central processor (CPU)

Lecture 29. Friday, March 23 CS 470 Operating Systems - Lecture 29 1

Operating Systems. V. Input / Output

I/O 1. Devices and I/O. key concepts device registers, device drivers, program-controlled I/O, DMA, polling, disk drives, disk head scheduling

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

Hard Disk Drives (HDDs) Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Chapter 12: Secondary-Storage Structure. Operating System Concepts 8 th Edition,

CISC 7310X. C11: Mass Storage. Hui Chen Department of Computer & Information Science CUNY Brooklyn College. 4/19/2018 CUNY Brooklyn College

Chapter 10: Mass-Storage Systems

Hard Disk Drives (HDDs)

Disks and RAID. CS 4410 Operating Systems. [R. Agarwal, L. Alvisi, A. Bracy, E. Sirer, R. Van Renesse]

CSCI-GA Operating Systems I/O. Hubertus Franke

Chapter 12: Mass-Storage

Storage Systems. Storage Systems

Chapter 12: Mass-Storage

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

Devices and Device Controllers. secondary storage (disks, tape) and storage controllers

Bus Architecture Example

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

Chapter 10: Mass-Storage Systems. Operating System Concepts 9 th Edition

Chapter 14: Mass-Storage Systems

Part IV I/O System. Chapter 12: Mass Storage Structure

Input Output (IO) Management

Lecture 16: Storage Devices

Mass-Storage. ICS332 Operating Systems

Module 13: Secondary-Storage

Introduction to I/O and Disk Management

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.

Introduction to I/O and Disk Management

Computer Organization and Structure. Bing-Yu Chen National Taiwan University

Mass-Storage Structure

Where We Are in This Course Right Now. ECE 152 Introduction to Computer Architecture Input/Output (I/O) Copyright 2012 Daniel J. Sorin Duke University

Readings. Storage Hierarchy III: I/O System. I/O (Disk) Performance. I/O Device Characteristics. often boring, but still quite important

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

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.

Transcription:

Input/Output : I/O Systems Principles of I/O hardware Principles of I/O software I/O software layers Disks Clocks Character-oriented terminals Graphical user interfaces Network terminals Power management 2 How fast is I/O hardware? Device controllers Device Keyboard Mouse 56K modem Printer / scanner USB Digital camcorder Fast Ethernet Hard drive FireWire (IEEE 1394) XGA monitor PCI bus Data rate 10 bytes/sec 100 bytes/sec 7KB/sec 200 KB/sec 1.5 MB/sec 4MB/sec 12.5 MB/sec 20 MB/sec 50 MB/sec 60 MB/sec 500 MB/sec I/O devices have components Mechanical component Electronic component Electronic component controls the device May be able to handle multiple devices May be more than one controller per mechanical component (example: hard drive) Controller's tasks Convert serial bit stream to block of bytes Perform error correction as necessary Make available to main memory 3 4 Memory-Mapped I/O How is memory-mapped I/O done? 0xFFF 0 Memory Separate I/O & memory I/O ports Memory-mapped I/O Hybrid: both memory-mapped & separate s Single-bus All memory accesses go over asharedbus I/O and RAM accesses compete for bandwidth Dual-bus RAM access over high-speed bus I/O access over lower-speed bus Less competition More hardware (more expensive ) CPU Memory I/O CPU Memory I/O This port allows I/O devices access into memory 5 6 1

Direct Memory Access (DMA) operation Hardware s view of interrupts Bus 7 I/O software: goals Programmed I/O: printing a page Device independence Programs can access any I/O device No need to specify device in advance Uniform naming Nameofafileordeviceisastringoraninteger Doesn t depend on the machine (underlying hardware) Error handling Done as close to the hardware as possible Isolate higher-level software Synchronous vs. asynchronous transfers Blocked transfers vs. interrupt-driven Buffering Data coming off a device cannot be stored in final destination Sharable vs. dedicated devices Kernel ABCD EFGH Printed page ABCD EFGH ABCD EFGH Printed page A ABCD EFGH ABCD EFGH Printed page AB 9 10 Code for programmed I/O Interrupt-driven I/O copy_from_user (buffer, p, count); // copy into kernel buffer for (j = 0; j < count; j++) { // loop for each char while (*printer_status_reg!= READY) ; // wait for printer to be ready *printer_data_reg = p[j]; // output a single character } return_to_user(); copy_from_user (buffer, p, count); j=0; enable_interrupts(); while (*printer_status_reg!= READY) ; *printer_data_reg = p[0]; scheduler(); // and block user if (count == 0) { unblock_user(); }else{ *printer_data_reg = p[j]; count--; j++; } acknowledge_interrupt(); return_from_interrupt(); Coderunbysystemcall Code run at interrupt time 11 12 2

I/O using DMA Layers of I/O software copy_from_user (buffer, p, count); set_up_dma_controller(); scheduler(); // and block user Coderunbysystemcall -level I/O software & libraries acknowledge_interrupt(); unblock_user(); return_from_interrupt(); Code run at interrupt time Device-independent OS software Device drivers Interrupt handlers Operating system (kernel) Hardware 13 14 Interrupt handlers Interrupt handlers are best hidden Driver starts an I/O operation and blocks Interrupt notifies of completion Interrupt procedure does its task Then unblocks driver that started it Perform minimal actions at interrupt time Some of the functionality can be done by the driver after it is unblocked Interrupt handler must Save regs not already saved by interrupt hardware Set up context for interrupt service procedure DLXOS: intrhandler (in dlxos.s) What happens on an interrupt Set up stack for interrupt service procedure Ack interrupt controller, reenable interrupts Copy registers from where saved Run service procedure (optional) Pick a new process to run next Set up MMU context for process to run next Load new process' registers Start running the new process 15 16 Device drivers Device-independent I/O software Device drivers go between device controllers and rest of OS Drivers standardize interface to widely varied devices Device drivers communicate with controllers over bus Controllers communicate with devices themselves Kernel Keyboard driver Keyboard controller program Rest of the OS Disk driver Disk controller Device-independent I/O software provides common library routines for I/O software Helps drivers maintain a standard appearance to the rest of the OS Uniform interface for many device drivers for Buffering Error reporting Allocating and releasing dedicated devices Suspending and resuming processes Common resource pool Device-independent block size (keep track of blocks) Other device driver resources 17 1 3

Why a standard driver interface? Buffering device input Kernel Kernel Kernel 2 Kernel 2 1 Non-standard driver interfaces Standard driver interfaces Unbuffered input 19 Buffering in user Buffer in kernel Copy to user Anatomy of an I/O request Data stored on surfaces Up to two surfaces per platter One or more platters per disk Data in concentric tracks Tracks broken into sectors 256B-1KB per sector Cylinder: corresponding tracks on all surfaces Data read and written by heads Double buffer in kernel 20 head sector platter track cylinder surfaces Actuator moves heads Heads move in unison spindle 21 Disk drive specifics actuator 22 24 Disk zones IBM 360KB floppy WD 1GB HD Outside tracks are longer than inside tracks Two options Cylinders 40 10601 Tracks per cylinder 2 12 Sectors per track 9 21 (average) Sectors per disk 720 35742000 Bytes per sector 512 512 Capacity 360 KB 1.3 GB Seek time (minimum) 6 ms 0. ms Seek time (average) ms 6.9 ms Rotation time 200 ms.33 ms Spinup time 250 ms 20 sec Sector transfer time 22 ms 17 µsec 3 Disk drive structure 1 Modern hard drives use second option Disk divided into zones 23 Bits are bigger More bits (transfer faster) More data on outer tracks Constant sectors per track in each zone 20 (or more) zones on a disk 4

Disk addressing Millions of sectors on the disk must be labeled Two possibilities Cylinder/track/sector Sequential numbering Modern drives use sequential numbers Disks map sequential numbers into specific location Mapping may be modified by the disk Remap bad sectors Optimize performance Hide the exact geometry, making life simpler for the OS Buildingabetter disk Problem: CPU performance has been increasing exponentially, but disk performance hasn t Disks are limited by mechanics Problem: disks aren t all that reliable Solution: distribute data across disks, and use some of the to improve reliability Data transferred in parallel Data stored across drives (striping) Parity on an extra drive for reliability 25 26 RAIDs, RAIDs, and more RAIDs CD-ROM recording strip strip Stripe RAID 0 (Redudant Array of Inexpensive Disks RAID 1 (Mirrored copies) RAID 4 (Striped with parity) CD-ROM has data in a spiral Hard drives have concentric circles of data One continuous track: just like vinyl records! Pits & lands simulated with heat-sensitive material on CD-Rs and CD-RWs RAID 5 (Parity rotates through disks) 27 2 Structure of a disk sector Preamble Data ECC Preamble contains information about the sector Sector number & location information Data is usually 256, 512, or 1024 bytes ECC (Error Correcting Code) is used to detect & correct minor errors in the data Sector layout on disk Sectors numbered sequentially on each track Numbering starts in different place on each track: sector skew Allows time for switching head from track to track All done to minimize delay in sequential transfers 29 30 5

Sector interleaving On older systems, the CPU was slow => time elapsed between reading consecutive sectors Solution: leave between consecutively numbered sectors This isn t done much these days 7 0 7 0 5 0 6 5 1 2 3 6 4 1 2 7 3 6 4 3 2 5 4 1 No interleaving Skipping 1 sector Skipping 2 sectors What s in a disk request? Timerequiredtoreadorwriteadiskblock determined by 3 factors Seek time Rotational delay Average delay = 1/2 rotation time Example: rotate in 10ms, average rotation delay = 5ms Actual transfer time Transfer time = time to rotate over sector Example: rotate in 10ms, 200 sectors/track => 10/200 ms = 0.05ms transfer time per sector Seek time dominates, with rotation time close Error checking is done by controllers 31 32 Disk request scheduling Goal: use disk hardware efficiently Bandwidthashighaspossible Disk transferring as often as possible (and not seeking) We want to Minimize disk seek time (moving from track to track) Minimize rotational latency (waiting for disk to rotate the desired sector under the read/write head) Calculate disk bandwidth by Total bytes transferred / time to service request Seek time & rotational latency are overhead (no data is transferred), and reduce disk bandwidth Minimize seek time & rotational latency by Using algorithms to find a good sequence for servicing requests Placing blocks of a given file near each other Disk scheduling algorithms Schedule disk requests to minimize disk seek time Seek time increases as distance increases (though not linearly) Minimize seek distance -> minimize seek time Disk seek algorithm examples assume a request queue & head position (disk has 200 cylinders) Queue = 100,, 51, 133,,, 73, Head position = 63 Outside edge read/write head position Inside edge 51 73 100 133 disk requests (cylinder in which block resides) 33 34 First-Come-First Served (FCFS) Requests serviced in the order in which they arrived Easy to implement! May involve lots of unnecessary seek distance Seek order = 100,, 51, 133,,, 73, Seek distance = (100-63) + (-100) + (-51) + (133-51) + (133-) + (-) + (-73) + (-73) = 646 cylinders Shortest Seek Time First (SSTF) Service the request with the shortest seek time from the current head position Form of SJF scheduling May starve some requests Seek order = 73,, 51,, 100, 133,, Seek distance = 10 + 4 + 26 + 43 + 92 + 33 + 7 + 35 = 250 cylinders read/write head start 51 73 100 133 read/write head start 51 73 100 133 35 36 6

SCAN (elevator algorithm) Disk arm starts at one end of the disk and moves towards the other end, servicing requests as it goes Reverses direction when it gets to end of the disk Also known as elevator algorithm Seek order = 51,, 0, 73,, 100, 133,, Seek distance = 12 + 43 + + 73 + 4 + 23 + 33 + 7 + 35 = 23 cyls C-SCAN Identical to SCAN, except head returns to cylinder 0 when it reaches the end of the disk Treats cylinder list as a circular list that wraps around the disk Waiting time is more uniform for cylinders near the edge of the disk Seek order = 73,, 100, 133,,, 199, 0,, 51 Distance=10+4+23+33+7+35+24+199++43=36cyls read/write head start 51 73 100 133 read/write head start 51 73 100 133 37 3 C-LOOK Identical to C-SCAN, except head only travels as far as the last request in each direction Saves seek time from last sector to end of disk Seek order = 73,, 100, 133,,,, 51 Distance = 10 + 4 + 23 + 33 + 7 + 35 + 167 + 43 = 322 cylinders read/write head start 51 73 100 133 39 How to pick a disk scheduling algorithm SSTF is easy to implement and works OK if there aren ttoo many disk requests in the queue SCAN-type algorithms perform better for systems under heavy load More fair than SSTF Use LOOK rather than SCAN algorithms to save time Long seeks aren t too expensive, so choose C-LOOK over LOOK to make response time more even Disk request scheduling interacts with algorithms for allocating blocks to files Make scheduling algorithm modular: allow it to be changed without changing the file system Use SSTF for lightly loaded systems Use C-LOOK for heavily loaded systems 40 When good disks go bad Clock hardware Disks have defects In 3M+ sectors, this isn t surprising! ECC helps with errors, but sometimes this isn t enough Disks keep spare sectors (normally unused) and remap bad sectors into these spares If there s time, the whole track could be reordered 41 42 7

Maintaining time of day Doing multiple timers with a single clock 43 44 Soft timers A second clock may be available for timer interrupts Specified by applications No problems if interrupt frequency is low Soft timers avoid interrupts Kernel checks for soft timer expiration before it exits to user mode How well this works depends on rate of kernel entries Character-oriented terminals An RS-232 terminal communicates with computer 1 bit at a time Called a serial line bits go out in series, 1 bit at a time Windows uses COM1 and COM2 ports, first to serial lines Computer and terminal are completely independent 45 46 Buffering for input Special terminal characters 47 4

Special output characters Memory-mapped display Parallel port Driver writes directly into display's video RAM 49 50 How characters are displayed Input software Keyboard driver delivers a number Driver converts to characters Uses a ASCII table Exceptions, adaptations needed for other languages Many OS provide for loadable keymaps or code pages Example: characters such as ç AvideoRAMimage simple monochrome display character mode Corresponding screen the xs are attribute bytes 51 52 Output software for Windows Skeleton of a Windows program Sample window located at (200,100) on XGA display 53 54 9

Skeleton of a Windows program (cont d) Character outlines at different point sizes 55 56 XWindows Architecture of the SLIM terminal system 57 5 The SLIM Network Terminal Power Management (1) Power consumption of various parts of a laptop computer 59 60 10

Power management (2) Power Management (3) The use of zones for backlighting the display Running at full clock speed Cutting voltage by two cuts clock speed by two, cuts power by four 61 62 Power Management (4) Telling the programs to use less energy may mean poorer user experience Examples change from color output to black and white speech recognition reduces vocabulary less resolution or detail in an image 63 11