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

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

CSE 120. Operating Systems. March 27, 2014 Lecture 17. Mass Storage. Instructor: Neil Rhodes. Wednesday, March 26, 14

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

CSE 380 Computer Operating Systems

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

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

I/O CANNOT BE IGNORED

Introduction. Operating Systems. Outline. Hardware. I/O Device Types. Device Controllers. One OS function is to control devices

Operating Systems 2010/2011

CSE380 - Operating Systems. Communicating with Devices

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

Introduction. Operating Systems. Outline. Hardware. I/O Device Types. Device Controllers. (done)

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

Storage. Hwansoo Han

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

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

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

Input Output (IO) Management

Introduction. Operating Systems. Outline. Hardware. I/O Device Types. Device Controllers. One OS function is to control devices

Computer Architecture CS 355 Busses & I/O System

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?

OPERATING SYSTEMS CS136

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

Operating Systems. Operating Systems Professor Sina Meraji U of T

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

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

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

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

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

CSE 153 Design of Operating Systems Fall 2018

Chapter 11. I/O Management and Disk Scheduling

I/O CANNOT BE IGNORED

Operating Systems. V. Input / Output

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

[08] IO SUBSYSTEM 1. 1

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.

Operating Systems. V. Input / Output. Eurecom

Chap. 3. Input/Output

Module 11: I/O Systems

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

CSE506: Operating Systems CSE 506: Operating Systems

I/O Management and Disk Scheduling. Chapter 11

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

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

CSE 153 Design of Operating Systems

[537] I/O Devices/Disks. Tyler Harter

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

Hard Disk Drives (HDDs)

Introduction I/O 1. I/O devices can be characterized by Behavior: input, output, storage Partner: human or machine Data rate: bytes/sec, transfers/sec

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

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

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

I/O Systems and Storage Devices

Input/Output Management

Chapter 6. Storage and Other I/O Topics

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

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

Chapter 5 - Input / Output

Systems Architecture II

Lecture 23: Storage Systems. Topics: disk access, bus design, evaluation metrics, RAID (Sections )

I/O and Device Drivers

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

Input/Output Systems

STORAGE SYSTEMS. Operating Systems 2015 Spring by Euiseong Seo

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

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

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

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

Silberschatz and Galvin Chapter 12

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

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

Bus Architecture Example

Module 12: I/O Systems

Module 12: I/O Systems

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

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

-Device. -Physical or virtual thing that does something -Software + hardware to operate a device (Controller runs port, Bus, device)

CPS104 Computer Organization and Programming Lecture 18: Input-Output. Outline of Today s Lecture. The Big Picture: Where are We Now?

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.

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

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

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

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

Chapter 13: Mass-Storage Systems. Disk Structure

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

Operating System 1 (ECS-501)

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

Lecture 13. Storage, Network and Other Peripherals

Lecture 21 Disk Devices and Timers

Chapter 13: I/O Systems

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

Computer Architecture Computer Science & Engineering. Chapter 6. Storage and Other I/O Topics BK TP.HCM

Chapter 12: Mass-Storage

C02: Interrupts and I/O

Chapter 11 I/O Management and Disk Scheduling

Operating Systems 2010/2011

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

Ricardo Rocha. Department of Computer Science Faculty of Sciences University of Porto

Chapter 6. Storage and Other I/O Topics

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

Transcription:

CSE 120 July 27, 2006 Day 8 Input/Output Instructor: Neil Rhodes How hardware works Operating Systems Layer What the kernel does API What the programmer does Overview 2 Kinds Block devices: read/write a block independent of all others drive Floppy drive USB pendrive Character devices: read/write one or more bytes Keyboard Mouse Serial Network Printer Miscellaneous Memory-mapped video Video chips Clock Bus: a set of wires and protocol for communicating ISA PCI Memory bus Daisy chain: bus with cables going from one device to the next USB SCSI Firewire Main Memory PCI Bridge CPU Graphics Controller Monitor Keyboard Mouse USB Universal Serial Bus (USB) PCI Bus SCSI SCSI Bus Level 2 Cache IDE Controller 3 4

Controllers Communicating with a Controller Simple Serial controller has buffer of several bytes Complex SCSI controller reads data from drive serially into block of memory inside controller Returns that block of data once block is completely read Communication between CPU and controller Registers Data in Data out Status Control How to access? Memory-mapped I/O - Registers are in a portion of memory space. Device controller looks for memory accesses in its own area of space. Using I/O ports - Separate instructions for reading and writing port address space. (Separate bit on the bus specifies I/O space rather than memory space). 5 Polling write (busy-wait): CPU: loop while busy bit in status is set Set write bit in control. Write data byte into data-out Set command-ready bit in control loop while busy bit in status is set Check error Controller: loop while command-ready bit in control is not set Set busy bit in status Since write bit in control is set, read data-out do I/O Clear command-ready bit in control Clear error bit in status Clear busy bit in status 6 Communicating with a Controller Interrupt-driven I/O CPU: loop while busy bit in status is set Set write bit in control. Write data byte into data-out Set command-ready bit in control Continue processing Process interrupt Controller: loop while command-ready bit in control is not set Set busy bit in status Since write bit in control is set, read data-out do I/O Clear command-ready bit in control Clear error bit in status Clear busy bit in status Issue interrupt 7 Interrupt Levels Interrupts Specifies priority of an interrupt; higher-level interrupts are serviced before lower-level ones Non-Maskable Interrupt (NMI) One that the processor can t ignore. Debugging button, for example Interrupt Controller will: Be notified by hardware controller that it wishes to interrupt Check to see whether there s an already-pending interrupt of same or higher priority If not, put interrupt address (small number) on bus, and generate interrupt signal to CPU CPU will: Check for interrupt signal after every instruction On interrupt (if not masked), save minimal state Use interrupt vector (table at well-known location) to jump to interrupt service routine (ISR) ISR will acknowledge the interrupt when it is ready to handle another interrupt Handle condition that caused interrupt (wake sleeping process) Restore state 8

Direct Memory Access (DMA) Layers of I/O Software Without DMA CPU must transfer information form device controller to main memory by reading/writing data one byte/word at a time (programmed I/O) Idea: Have DMA controller that will do the transfer on behalf of the CPU Sometimes build into device controller (must be a bus master) CPU programs the DMA controller to specify source, destination, and amount DMA controller loops: Seize memory bus (cycle stealing) Tell device controller to write to memory address Release memory bus When complete, issue interrupt to CPU Usually used for device generating lots of data, video Not keyboard, for example User Space Kernel IDE Driver IDE ISR Rest of the process U User-level I/O software Device-Independent I/O Software IDE Controller Need picture Keyboard Driver Keyboard ISR bus USB Controller disk keyboard 9 10 Initialize Probe whether device is there Figure out interrupt address (usually known by device controller) Allocate data structures Open Install ISR Enable interrupts on controller Close Disable interrupts on controller Uninstall ISR Read Read data from device Write Write data to device ioctl Device-specific functionality Set baud rate, for example ISR Device Driver Functionality Not called directly, but only in response to an interrupt Uniformity Uniform interface between OS and drivers Unix character devices read write open close ioctl Unix block devices (buffered in kernel memory) open close strategy - Given a buffer header with address, read/write bit, block number,word count, major/minor device number Uniform interface between user programs and devices Unix, for example inode specifics block vs. character and major/minor device numbers - Major number used as index into table of drivers - Minor number used to specify which device which partition on disk which serial port 11 12

Unbuffered Buffering Driver reads directly into user space, one byte at a time read(fd, &ch, 1); Disadvantage: must wake up user process on every byte Buffered in user space Driver reads directly into a buffer in user space read(fd, buffer, sizeof(buffer)); Disadvantage: must lock the page in memory Buffered in kernel Driver reads into a buffer in the kernel When buffer is full, copied to user space Disadvantage: copying takes time. Buffer may overflow Double-buffering in kernel Driver reads into a buffer in the kernel When buffer is full, copied to user space While copying (or waiting for user space page to be paged in), use separate buffer for incoming data Disadvantage: more memory used in the kernel Buffering and Performance Write a network packet Assemble packet in user space Write Copies to kernel buffer Driver Copies to controller buffer Controller Moves onto network On remote end: Controller assembles into controller buffer Driver Copies from controller buffer to kernel buffer Read Copies from kernel buffer to user space 13 14 User-space I/O software Buffering in user-space All FILE* routines: fputc, putchar, getchar Formatting routines: sprintf, printf, etc. Library interfaces to system calls write Small assembly-language stub that marshals parameters and issues system call read etc. Spooling printing a file UUCP (Unix to Unix Copy) Head Assembly Head Platter s Track Sector Time to access a block (sector) Seek time (time to move the head in or out to the appropriate track) Rotational latency (time for the disk to spin so that the beginning of the sector is under the head) Transfer time (time for the data to be read from the sector). 15 16

Specs Western Digital Raptor X WD1500AHFD Hitachi Deskstar 7K250 Capacity 72 GB 250 GB Rotational Speed 10,000 RPM 7,200 RPM Average rotational latency 3 ms 4 ms Average seek time 5 ms 8.5 ms Average sustained transfer rate 84 MB/s 60 MB/s Buffer size 16 MB 8 MB RAID Redundant Array of Inexpensive s (compared to SLED: Single large Expensive ) Bunch of disks controlled by a RAID card Looks like SLED to operating system, but provides better performance and better reliability Level 0 Striping Parallel read (for large read requests) Worse reliability Level 1 Every strip is written twice Read from one disk while busy with another 1 2 DIsk 3 Block 1-k LBN 1-k LBN k-2k LBN 2k-3k Block k-2k LBN 3k-4k LBN 4k-5k LBN 5k-6k Block 2k-3k LBN 6k-7k LBN 7k-8k LBN 8k-9k 1 2 DIsk 3 DIsk 4 5 6 Block 1-k LBN 1-k LBN k-2k LBN 2k-3k LBN 1-k LBN k-2k LBN 2k-3k Block k-2k LBN 3k-4k LBN 4k-5k LBN 5k-6k LBN 3k-4k LBN 4k-5k LBN 5k-6k Block 2k-3k LBN 6k-7k LBN 7k-8k LBN 8k-9k LBN 6k-7k LBN 7k-8k LBN 8k-9k 17 18 Level 2 Break each word into bits Add Hamming code can correct any 1-bit error can detect any 2-bit error Can lose any one drive RAID s must be synchronized (rotational position and head location) Throughput increased by 16x Level 3 One extra parity drive Similar to level 2 Can t correct silent errors 1 2 DIsk 3 21 Bit 1 Err bit Err bit Bit 1 Bit 16 Bit 2 Err bit Err bit Bit 1 Bit 16 Bit 3 Err bit Err bit Bit 1 Bit 16 1 2 16 17 Bit 1 Err bit Err bit Bit 16 parity Bit 2 Err bit Err bit Bit 16 parity Bit 3 Err bit Err bit Bit 16 parity Level 4 RAID Like level 0, but with extra parity drive On write, must re-read all strips to recalculate parity Or, can pre-read old parity and data to compute new parity Parity drive may become bottleneck (used on every write) Level 5 Like level 4, but with parity strip spread across drives 1 2 DIsk 3 DIsk 4 Block 1-k LBN 1-k LBN k-2k LBN 2k-3k Parity 1-3K Block k-2k LBN 3k-4k LBN 4k-5k LBN 5k-6k Parity 3k-4k Block 2k-3k LBN 6k-7k LBN 7k-8k LBN 8k-9k Parity 6k-7k 1 2 DIsk 3 DIsk 4 Block 1-k LBN 1-k LBN k-2k LBN 2k-3k Parity 1-3K Block k-2k LBN 3k-4k LBN 4k-5k Parity 3K-6K LBN 5k-6k Block 2k-3k LBN 6k-7k Pairty 6K-9K LBN 7K-8K LBN 8K-9 19 20

-Arm Scheduling Algorithms Reducing seek time will increase system performance First Come First Serve (FCFS) Can require lots of seeking (imagine queue containing cylinder, cylinder n, cylinder 2, cylinder n-5) Shortest Seek First (SSF) From among the cylinders in the queue, go to the one that s nearest Can increase throughput Disadvantage: Imaging queue contains request for block in cylinder 1, but other requests keep coming in that are closer to the disk arm. A request can be indefinitely delayed. Elevator (or SCAN) Keep state of moving up or down. Move the disk arm to next-closest requested higher cylinder (if moving up, otherwise lower cylinder). If no higher cylinder, switch direction. Circular Scan (CSCAN) Like Elevator, but always go up. When at end, move to lowest requested cylinder without servicing requests in-between. Scenario: Anticipatory Scheduling Imagine two processes p and q each writing to 10 MB disk file. If running alone, each takes 5 seconds. How long to run together? p and q will issue requests If p is satisfied first, scheduling algorithm will try to satisfy q s request. When p runs, it ll issue another write request - By that time, the disk head has moved way off. Solution: Add anticipation to any disk-scheduling algorithm. Simple explanation The last process that issued a request will probably issue another one soon (in same general location) If request we d otherwise do is not close, instead of moving the disk head, delay and do nothing for a short time If request comes in from process during that time, stop waiting - and, presumably, read/write that requested (close) disk block If timer expires, continue with disk-scheduling algorithm Benefits Decreased latency, increased bandwidth 21 22 Reference Anticipatory Scheduling Sitaram Ayer, 2001, <http://www.cs.rice.edu/~ssiyer/r/antsched/> Implementation: Linux Streaming read while streaming write taking place Without anticipatory: 42, 48, 47 seconds With anticipatory: 3.8 seconds Reading many small files while streaming write taking place Without anticipatory: >15:00, 7:27, 9:55 minutes:seconds With anticipatoy: 17 seconds More formally benefit = CaculateSeekTime(candidate) - Expected seek time of process cost = max(0, expected median think time of process - elapsed time) duration = max(0, expected 95th percentile think time of process - elapsed time) if (benefit > cost) time_to_wait = duration else don t wait Bad Blocks Low-level format (at factory) reserves blocks Not all at beginning or end, but spread out across disk Controller will detect bad blocks and either: Spare a block (for example, if block 17 is bad, remap it to block 120) Skip a contiguous section of blocks If block 17 is bad and first reserved block is 120, remap blocks 17-119 to 18-120 (and move blocks 18-119 up one) Drive controller can report information on bad blocks, etc. to OS SMART (Self-Monitoring, Analysis and Reporting Technology) 23 24