Persistence: I/O devices

Slides:



Advertisements
Similar presentations
IT253: Computer Organization
Advertisements

Lecture 14 I/O Devices & Hard Disk Drives. vgetmem only from private heap.
04/18/2007CSCI 315 Operating Systems Design1 Mass Storage Structure Notice: The slides for this lecture have been largely based on those accompanying the.
11/18/2004Comp 120 Fall November 3 classes to go No class on Tuesday 23 November Last 2 classes will be survey and exam review Interconnect and.
1 Storage Hierarchy Cache Main Memory Virtual Memory File System Tertiary Storage Programs DBMS Capacity & Cost Secondary Storage.
Avishai Wool lecture Introduction to Systems Programming Lecture 9 Input-Output Devices.
04/19/2004CSCI 315 Operating Systems Design1 Mass Storage Structure Notice: The slides for this lecture have been largely based on those accompanying the.
Introduction to Database Systems 1 The Storage Hierarchy and Magnetic Disks Storage Technology: Topic 1.
Disk-based Storage Oct. 23, 2008 Topics Storage technologies and trends Locality of reference Caching in the memory hierarchy lecture-17.ppt “The.
CS4432: Database Systems II Data Storage (Better Block Organization) 1.
Disk Memory Topics Disk Memory Structure Disk Capacity class10.ppt.
Device Management. So far… We have covered CPU and memory management Computing is not interesting without I/Os Device management: the OS component that.
Storage & Peripherals Disks, Networks, and Other Devices.
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.
Comp 335 – File Structures Why File Structures?. Goal of the Class To develop an understanding of the file I/O process. Software must be able to interact.
I/O Example: Disk Drives To access data: — seek: position head over the proper track (8 to 20 ms. avg.) — rotational latency: wait for desired sector (.5.
Lecture No 11 Storage Devices
CS 3204 Operating Systems Godmar Back Lecture 22.
Lecture 3 Page 1 CS 111 Online Disk Drives An especially important and complex form of I/O device Still the primary method of providing stable storage.
UNIVERSITY of WISCONSIN-MADISON Computer Sciences Department
12/18/20151 Operating Systems Design (CS 423) Elsa L Gunter 2112 SC, UIUC Based on slides by Roy Campbell, Sam.
Adapted from Computer Organization and Design, Patterson & Hennessy ECE232: Hardware Organization and Design Part 17: Input/Output Chapter 6
Processor Memory Processor-memory bus I/O Device Bus Adapter I/O Device I/O Device Bus Adapter I/O Device I/O Device Expansion bus I/O Bus.
Input Output Techniques Programmed Interrupt driven Direct Memory Access (DMA)
Device Management Mark Stanovich Operating Systems COP 4610.
Device Management Andy Wang Operating Systems COP 4610 / CGS 5765.
10/15: Lecture Topics Input/Output –Types of I/O Devices –How devices communicate with the rest of the system communicating with the processor communicating.
CS 61C: Great Ideas in Computer Architecture (Machine Structures) More I/O: DMA Vladimir Stojanovic & Nicholas Weaver
Lecture 17 Raid. Device Protocol Variants Status checks: polling vs. interrupts Data: PIO vs. DMA Control: special instructions vs. memory-mapped I/O.
CSCE 385: Computer Architecture Spring 2014 Dr. Mike Turi I/O.
File organization Secondary Storage Devices Lec#7 Presenter: Dr Emad Nabil.
I/O Devices.
Chapter 13: I/O Systems Modified by Dr. Neerja Mhaskar for CS 3SH3.
Sarah Diesburg Operating Systems CS 3430
Chapter 2: Computer-System Structures
Input/Output Devices ENCE 360
Disks and RAID.
Database Management Systems (CS 564)
Operating Systems (CS 340 D)
OPERATING SYSTEMS CS 3502 Fall 2017
Computer Science 210 Computer Organization
Backing Store.
CPSC-608 Database Systems
Introduction to Computing
CS 286 Computer Organization and Architecture
Mass-Storage Structure
CS703 - Advanced Operating Systems
Computer Architecture
Lecture 11: DMBS Internals
Introduction to I/O Where does the data for our CPU and memory come from or go to? Computers communicate with the outside world via I/O devices. Input.
CSCI 315 Operating Systems Design
CSE 153 Design of Operating Systems Winter 2018
Lecture 13 I/O.
Device Management Damian Gordon.
Lecture 9: Data Storage and IO Models
Secondary Storage Devices
Direct Memory Access Disk and Network transfers: awkward timing:
Today’s agenda Hardware architecture and runtime system
CSE 451: Operating Systems Autumn 2003 Lecture 12 Secondary Storage
Persistence: hard disk drive
CSE 451: Operating Systems Winter 2003 Lecture 12 Secondary Storage
Outline Device Management Device Manager Design Buffering
Disks and Disk Scheduling
Secondary Storage Management Hank Levy
CSE451 File System Introduction and Disk Drivers Autumn 2002
Chapter 11: Mass-Storage Systems
Andy Wang Operating Systems COP 4610 / CGS 5765
Chapter 5 Input/Output Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved
Presentation transcript:

Persistence: I/O devices Questions answered in this lecture: How does the OS interact with I/O devices (check status, send data+control)? What is a device driver? What are the components of a hard disk drive?

Motivation What good is a computer without any I/O devices? - keyboard, display, disks We want: - H/W that will let us plug in different devices - OS that can interact with different combinations

Hardware support for I/O CPU RAM Memory Bus General I/O Bus (e.g., PCI) Graphics Peripheral I/O Bus (e.g., SCSI, SATA, USB) Why use hierarchical buses?

OS reads/writes to these Canonical Device OS reads/writes to these Device Registers: Status COMMAND DATA

OS reads/writes to these Canonical Device OS reads/writes to these Device Registers: Status COMMAND DATA Hidden Internals: ???

OS reads/writes to these Canonical Device OS reads/writes to these Device Registers: Status COMMAND DATA Microcontroller (CPU+RAM) Extra RAM Other special-purpose chips Hidden Internals:

Example Write Protocol Status COMMAND DATA Microcontroller (CPU+RAM) Extra RAM Other special-purpose chips while (STATUS == BUSY) ; // spin Write data to DATA register Write command to COMMAND register

CPU: Disk: while (STATUS == BUSY) // 1 ; Write data to DATA register // 2 Write command to COMMAND register // 3 while (STATUS == BUSY) // 4

CPU: Disk: A C while (STATUS == BUSY) // 1 ; Write data to DATA register // 2 Write command to COMMAND register // 3 while (STATUS == BUSY) // 4

CPU: Disk: A C A wants to do I/O while (STATUS == BUSY) // 1 ; Write data to DATA register // 2 Write command to COMMAND register // 3 while (STATUS == BUSY) // 4

CPU: Disk: A C 1 while (STATUS == BUSY) // 1 ; Write data to DATA register // 2 Write command to COMMAND register // 3 while (STATUS == BUSY) // 4

CPU: Disk: A C A 1 2 while (STATUS == BUSY) // 1 ; Write data to DATA register // 2 Write command to COMMAND register // 3 while (STATUS == BUSY) // 4

CPU: Disk: A C A 3 1 2 while (STATUS == BUSY) // 1 ; Write data to DATA register // 2 Write command to COMMAND register // 3 while (STATUS == BUSY) // 4

CPU: Disk: A C A 3 1 2 4 while (STATUS == BUSY) // 1 ; Write data to DATA register // 2 Write command to COMMAND register // 3 while (STATUS == BUSY) // 4

CPU: Disk: A C A 3 1 2 4 while (STATUS == BUSY) // 1 ; Write data to DATA register // 2 Write command to COMMAND register // 3 while (STATUS == BUSY) // 4

CPU: Disk: how to avoid spinning? interrupts! A B C A 3 1 2 4 while (STATUS == BUSY) // 1 ; Write data to DATA register // 2 Write command to COMMAND register // 3 while (STATUS == BUSY) // 4 how to avoid spinning? interrupts!

how to avoid spinning? interrupts! CPU: Disk: A B C A 3 1 2 4 while (STATUS == BUSY) // 1 wait for interrupt; Write data to DATA register // 2 Write command to COMMAND register // 3 while (STATUS == BUSY) // 4

how to avoid spinning? interrupts! CPU: Disk: A B A B A B C A 3,4 1 2 while (STATUS == BUSY) // 1 wait for interrupt; Write data to DATA register // 2 Write command to COMMAND register // 3 while (STATUS == BUSY) // 4

Interrupts vs. Polling Are interrupts ever worse than polling? Fast device: Better to spin than take interrupt overhead Device time unknown? Hybrid approach (spin then use interrupts) Flood of interrupts arrive Can lead to livelock (always handling interrupts) Better to ignore interrupts while make some progress handling them Other improvement Interrupt coalescing (batch together several interrupts)

Protocol Variants Status checks: polling vs. interrupts COMMAND DATA Microcontroller (CPU+RAM) Extra RAM Other special-purpose chips Status checks: polling vs. interrupts Data: PIO vs. DMA Control: special instructions vs. memory-mapped I/O

what else can we optimize? 3,4 1 2 CPU: A B A B A B Disk: C A while (STATUS == BUSY) // 1 wait for interrupt; Write data to DATA register // 2 Write command to COMMAND register // 3 while (STATUS == BUSY) // 4 what else can we optimize? data transfer!

Programmed I/O vs. Direct Memory Access PIO (Programmed I/O): CPU directly tells device what the data is DMA (Direct Memory Access): CPU leaves data in memory Device reads data directly from memory

CPU: Disk: A B A B A B C A 3,4 1 2 while (STATUS == BUSY) // 1 wait for interrupt; Write data to DATA register // 2 Write command to COMMAND register // 3 while (STATUS == BUSY) // 4

CPU: Disk: A B A B A B C A 3,4 1 2 while (STATUS == BUSY) // 1 wait for interrupt; Write data to DATA register // 2 Write command to COMMAND register // 3 while (STATUS == BUSY) // 4

CPU: Disk: A B B A C A 1 3,4 while (STATUS == BUSY) // 1 wait for interrupt; Write data to DATA register // 2 Write command to COMMAND register // 3 while (STATUS == BUSY) // 4

Protocol Variants Status checks: polling vs. interrupts COMMAND DATA Microcontroller (CPU+RAM) Extra RAM Other special-purpose chips Status checks: polling vs. interrupts Data: PIO vs. DMA Control: special instructions vs. memory-mapped I/O

how does OS read and write registers? 1 3,4 CPU: A B B A Disk: C A while (STATUS == BUSY) // 1 wait for interrupt; Write data to DATA register // 2 Write command to COMMAND register // 3 while (STATUS == BUSY) // 4 how does OS read and write registers?

Special Instructions vs. Mem-Mapped I/O each device has a port in/out instructions (x86) communicate with device Memory-Mapped I/O H/W maps registers into address space loads/stores sent to device Doesn’t matter much (both are used)

Protocol Variants Status checks: polling vs. interrupts COMMAND DATA Microcontroller (CPU+RAM) Extra RAM Other special-purpose chips Status checks: polling vs. interrupts Data: PIO vs. DMA Control: special instructions vs. memory-mapped I/O

Variety is a Challenge Problem: many, many devices each has its own protocol How can we avoid writing a slightly different OS for each H/W combination? Write device driver for each device Drivers are 70% of Linux source code

Storage Stack application file system scheduler driver hard drive build common interface on top of all HDDs hard drive

Hard Disks

Basic Interface Disk has a sector-addressable address space Appears as an array of sectors Sectors are typically 512 bytes or 4096 bytes. Main operations: reads + writes to sectors Mechanical (slow) nature makes management “interesting”

Disk Internals Platter

Platter is covered with a magnetic film.

Spindle

Surface Surface

Many platters may be bound to the spindle.

Each surface is divided into rings called tracks. A stack of tracks (across platters) is called a cylinder.

The tracks are divided into numbered sectors. 23 16 15 8 22 17 7 14 9 6 1 5 2 13 10 4 3 21 18 12 11 20 19 The tracks are divided into numbered sectors.

Heads on a moving arm can read from each surface. 23 16 15 8 22 17 7 14 9 6 1 5 2 13 10 4 3 21 18 12 11 20 19 Heads on a moving arm can read from each surface.

Spindle/platters rapidly spin. 23 16 15 8 22 17 7 14 9 6 1 5 2 13 10 4 3 21 18 12 11 20 19 Spindle/platters rapidly spin.

Disk Terminology spindle read/write head platter surface sector track cylinder

Hard Drive Demo http://youtu.be/9eMWG3fwiEU?t=30s https://www.youtube.com/watch?v=L0nbo1VOF4M

Let’s Read 12! 1 2 3 6 5 4 7 8 9 10 11 15 14 13 12 16 17 18 19 23 22 21 20

Positioning Drive servo system keeps head on track Use servo burst: How does the disk head know where it is? Platters not perfectly aligned, tracks not perfectly concentric (runout) -- difficult to stay on track More difficult as density of disk increase More bits per inch (BPI), more tracks per inch (TPI) Use servo burst: Record placement information every few (3-5) sectors When head cross servo burst, figure out location and adjust as needed

Let’s Read 12! 1 2 3 6 5 4 7 8 9 10 11 15 14 13 12 16 17 18 19 23 22 21 20

Seek to right track. 1 2 3 6 5 4 7 8 9 10 11 15 14 13 12 16 17 18 19 23 22 21 20

Seek to right track. 1 2 3 6 5 4 7 8 9 10 11 15 14 13 12 16 17 18 19 23 22 21 20

Seek to right track. 1 2 3 6 5 4 7 8 9 10 11 15 14 13 12 16 17 18 19 23 22 21 20

Wait for rotation. 1 2 3 6 5 4 7 8 9 10 11 15 14 13 12 16 17 18 19 23 22 21 20

Wait for rotation. 1 2 3 6 5 4 7 8 9 10 11 15 14 13 12 16 17 18 19 23 22 21 20

Wait for rotation. 1 2 3 6 5 4 7 8 9 10 11 15 14 13 12 16 17 18 19 23 22 21 20

Wait for rotation. 1 2 3 6 5 4 7 8 9 10 11 15 14 13 12 16 17 18 19 23 22 21 20

Wait for rotation. 1 2 3 6 5 4 7 8 9 10 11 15 14 13 12 16 17 18 19 23 22 21 20

Wait for rotation. 1 2 3 6 5 4 7 8 9 10 11 15 14 13 12 16 17 18 19 23 22 21 20

Transfer data. 1 2 3 6 5 4 7 8 9 10 11 15 14 13 12 16 17 18 19 23 22 21 20

Transfer data. 1 2 3 6 5 4 7 8 9 10 11 15 14 13 12 16 17 18 19 23 22 21 20

Transfer data. 1 2 3 6 5 4 7 8 9 10 11 15 14 13 12 16 17 18 19 23 22 21 20

Yay! 1 2 3 6 5 4 7 8 9 10 11 15 14 13 12 16 17 18 19 23 22 21 20

Time to Read/write Three components: Time = seek + rotation + transfer time

Seek, Rotate, Transfer Seek cost: Function of cylinder distance Not purely linear cost Must accelerate, coast, decelerate, settle Settling alone can take 0.5 - 2 ms Entire seeks often takes several milliseconds 4 - 10 ms Approximate average seek distance = 1/3 max seek distance (why?)

Seek, Rotate, Transfer Depends on rotations per minute (RPM) 7200 RPM is common, 15000 RPM is high end. With 7200 RPM, how long to rotate around? 1 / 7200 RPM = 1 minute / 7200 rotations = 1 second / 120 rotations = 8.3 ms / rotation Average rotation? 8.3 ms / 2 = 4.15 ms

Seek, Rotate, Transfer Pretty fast — depends on RPM and sector density. 100+ MB/s is typical for maximum transfer rate How long to transfer 512-bytes? 512 bytes * (1s / 100 MB) = 5 us

Workload Performance So… - seeks are slow - rotations are slow - transfers are fast What kind of workload is fastest for disks? Sequential: access sectors in order (transfer dominated) Random: access sectors arbitrarily (seek+rotation dominated)