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

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

Hard Disk Drives. Nima Honarmand (Based on slides by Prof. Andrea Arpaci-Dusseau)

CS370 Operating Systems

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

UNIT 2 Data Center Environment

Hard Disk Drives (HDDs)

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

OPERATING SYSTEMS CS3502 Spring Input/Output System Chapter 9

CSE 153 Design of Operating Systems Fall 2018

CS420: Operating Systems. Mass Storage Structure

CSE 153 Design of Operating Systems

OPERATING SYSTEMS CS3502 Spring Input/Output System Chapter 9

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

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

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

Module 1: Basics and Background Lecture 4: Memory and Disk Accesses. The Lecture Contains: Memory organisation. Memory hierarchy. Disks.

CS3600 SYSTEMS AND NETWORKS

I/O CANNOT BE IGNORED

I/O CANNOT BE IGNORED

Computer Science 61C Spring Friedland and Weaver. Input/Output

Data Storage and Query Answering. Data Storage and Disk Structure (2)

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

Mass-Storage Structure

Reading and References. Input / Output. Why Input and Output? A typical organization. CSE 410, Spring 2004 Computer Systems

STORING DATA: DISK AND FILES

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

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

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

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

Appendix D: Storage Systems

Chapter 10: Mass-Storage Systems

CS429: Computer Organization and Architecture

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

I/O Devices. Nima Honarmand (Based on slides by Prof. Andrea Arpaci-Dusseau)

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

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

UNIVERSITY OF MASSACHUSETTS Dept. of Electrical & Computer Engineering. Computer Architecture ECE 568

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

Storage Technologies and the Memory Hierarchy

Adapted from instructor s supplementary material from Computer. Patterson & Hennessy, 2008, MK]

CS429: Computer Organization and Architecture

CSE 451: Operating Systems Winter Secondary Storage. Steve Gribble. Secondary storage

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

Overview of Mass Storage Structure

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

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

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

EIDE, ATA, SATA, USB,

Components of the Virtual Memory System

Database Systems II. Secondary Storage

Where Have We Been? Ch. 6 Memory Technology

CSE 451: Operating Systems Spring Module 12 Secondary Storage

Chapter 11. I/O Management and Disk Scheduling

Random-Access Memory (RAM) CS429: Computer Organization and Architecture. SRAM and DRAM. Flash / RAM Summary. Storage Technologies

Storage systems. Computer Systems Architecture CMSC 411 Unit 6 Storage Systems. (Hard) Disks. Disk and Tape Technologies. Disks (cont.

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

CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring 2002

Chapter 10: Mass-Storage Systems

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

CS 201 The Memory Hierarchy. Gerson Robboy Portland State University

CSE 451: Operating Systems Winter Lecture 12 Secondary Storage. Steve Gribble 323B Sieg Hall.

Concepts Introduced. I/O Cannot Be Ignored. Typical Collection of I/O Devices. I/O Issues

Administrivia. CMSC 411 Computer Systems Architecture Lecture 19 Storage Systems, cont. Disks (cont.) Disks - review

Storage Systems : Disks and SSDs. Manu Awasthi July 6 th 2018 Computer Architecture Summer School 2018

Principles of Data Management. Lecture #2 (Storing Data: Disks and Files)

Introduction to I/O and Disk Management

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

V. Mass Storage Systems

Introduction to I/O and Disk Management

STORAGE SYSTEMS. Operating Systems 2015 Spring by Euiseong Seo

Quiz for Chapter 6 Storage and Other I/O Topics 3.10

Computer Organization: A Programmer's Perspective

ECE232: Hardware Organization and Design

I/O Devices & SSD. Dongkun Shin, SKKU

CS162 Operating Systems and Systems Programming Lecture 17. Disk Management and File Systems

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

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

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

Disks & Files. Yanlei Diao UMass Amherst. Slides Courtesy of R. Ramakrishnan and J. Gehrke

UNIVERSITY OF MASSACHUSETTS Dept. of Electrical & Computer Engineering. Computer Architecture ECE 568

EECS 482 Introduction to Operating Systems

CSE 451: Operating Systems Spring Module 12 Secondary Storage. Steve Gribble

CS 33. Memory Hierarchy I. CS33 Intro to Computer Systems XVI 1 Copyright 2016 Thomas W. Doeppner. All rights reserved.

File. File System Implementation. File Metadata. File System Implementation. Direct Memory Access Cont. Hardware background: Direct Memory Access

Overview of Storage & Indexing (i)

CS370 Operating Systems

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 12: Secondary-Storage Structure. Operating System Concepts 8 th Edition,

2009. October. Semiconductor Business SAMSUNG Electronics

Mass-Storage Structure

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

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.

Storage Systems. Storage Systems

Some material adapted from Mohamed Younis, UMBC CMSC 611 Spr 2003 course slides Some material adapted from Hennessy & Patterson / 2003 Elsevier

6.033 Computer System Engineering

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

CS162 Operating Systems and Systems Programming Lecture 17. Disk Management and File Systems

Monday, May 4, Discs RAID: Introduction Error detection and correction Error detection: Simple parity Error correction: Hamming Codes

Storage System COSC UCB

Transcription:

CS 471 Operating Systems Yue Cheng George Mason University Fall 2017

Review: Memory Accesses 2

Impact of Program Structure on Memory Performance o Consider an array named data with 128*128 elements o Each row is stored in one page (of size 128 words) 3

Impact of Program Structure on Memory Performance o Consider an array named data with 128*128 elements o Each row is stored in one page (of size 128 words) o Program 1 for (j = 0; j <128; j++) for (i = 0; i < 128; i++) data[i][j] = 0; 128 x 128 = 16,384 page faults 4

Impact of Program Structure on Memory Performance o Consider an array named data with 128*128 elements o Each row is stored in one page (of size 128 words) o Program 1 for (j = 0; j <128; j++) for (i = 0; i < 128; i++) data[i][j] = 0; 128 x 128 = 16,384 page faults o Program 2 for (i = 0; i < 128; i++) for (j = 0; j < 128; j++) data[i][j] = 0; Only 128 page faults 5

I/O Devices 6

Why I/O? o I/O == Input/Output o What good is a computer without any I/O devices? Keyboard, display, disks 7

Why I/O? o I/O == Input/Output o What good is a computer without any I/O devices? Keyboard, display, disks o We want Hardware: which will provide direct physical interfaces OS: which can interact with different combinations 8

Prototypical System Architecture 9

Prototypical System Architecture 10

Prototypical System Architecture 11

Canonical I/O Device 12

Canonical I/O Device OS reads from and writes to these 13

Canonical I/O Device OS reads from and writes to these 14

Hard Disk Drive PCB Example 15

A Basic I/O Protocol while (STATUS == BUSY) ; // spin Write data to DATA register Write command to COMMAND register while (STATUS == BUSY) ; // spin 16

A Basic I/O Protocol CPU Disk A C while (STATUS == BUSY) //1 ; // spin Write data to DATA register //2 Write command to COMMAND register //3 while (STATUS == BUSY) //4 ; // spin 17

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

A Basic I/O Protocol 1 CPU Disk A C while (STATUS == BUSY) //1 ; // spin Write data to DATA register //2 Write command to COMMAND register //3 while (STATUS == BUSY) //4 ; // spin 19

A Basic I/O Protocol 1 2 3 CPU A Disk C A while (STATUS == BUSY) //1 ; // spin Write data to DATA register //2 Write command to COMMAND register //3 while (STATUS == BUSY) //4 ; // spin 20

A Basic I/O Protocol 1 2 3 4 CPU A Disk C A while (STATUS == BUSY) //1 ; // spin Write data to DATA register //2 Write command to COMMAND register //3 while (STATUS == BUSY) //4 ; // spin 21

A Basic I/O Protocol 1 polling 2 3 4 polling CPU A Disk C A Wasted CPU cycles while (STATUS == BUSY) //1 ; // spin Write data to DATA register //2 Write command to COMMAND register //3 while (STATUS == BUSY) //4 ; // spin 22

Interrupts 1 polling 2 3 4 polling CPU 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 wait for interrupt; 23

Interrupts 1 2 3, 4 CPU A B A 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 wait for interrupt; 24

Interrupts vs. Polling o Any potential issues for interrupts? 25

Interrupts vs. Polling o Any potential issues for interrupts? o Interrupts can lead to livelock E.g., flood of network packets 26

Interrupts vs. Polling o Any potential issues for interrupts? o Interrupts can lead to livelock E.g., flood of network packets o Techniques Hybrid approach: polling + interrupts Interrupt coalescing: batching a bunch interrupts in one go 27

Where else Can We Optimize? 1 2 3, 4 CPU A B A 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 wait for interrupt; 28

Data Transfer 1 2 3, 4 CPU A B A 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 wait for interrupt; 29

Programmed I/O vs. Direct Memory Access o PIO (Programmed I/O) CPU directly tells device what data is CPU involved in data transfer o DMA (Direct Memory Access) CPU leaves data in memory DMA hardware does data copy 30

Revisit: PIO Data Flow Disk 31

Revisit: DMA Data Flow Disk 32

DMA 1 2a 2b,3,4 CPU DMA A B B B A A Disk C A while (STATUS == BUSY) //1 wait for interrupt; Initiate DMA transfer //2a Wait for interrupt //2b Write command to COMMAND register //3 while (STATUS == BUSY) //4 wait for interrupt; 33

Hard Disk Drives (HDDs) 34

Basic Interface o A magnetic disk has a sector-addressable address space You can think of a disk as an array of sectors Each sector (logical block) is the smallest unit of transfer o Sectors are typically 512 or 4096 bytes o Main operations Read from sectors (blocks) Write to sectors (blocks) 35

Disk Structure o The 1-dimensional array of logical blocks is mapped into the sectors of the disk sequentially Sector 0 is the first sector of the first track on the outermost cylinder Mapping proceeds in order through that track, then the rest of the tracks in that cylinder, and then through the rest of the cylinders from outermost to innermost Logical to physical address should be easy Except for bad sectors 36

Internals of Hard Disk Drive (HDD) 37

Internals of Hard Disk Drive (HDD) Platter Covered with a magnetic film 38

Internals of Hard Disk Drive (HDD) A single track example 39

Internals of Hard Disk Drive (HDD) Spindle in the center of the surface 40

Internals of Hard Disk Drive (HDD) The track is divided into numbered sectors 41

Internals of Hard Disk Drive (HDD) A single track + an arm + a head 42

HDD Mechanism (3D view) track t spindle sector s arm assembly cylinder c read-write head platter arm rotation 43

Let s Read Sector 0 44

Let s Read Sector 0 1. Seek for right track 2. Rotate (sector 9 à 0) 3. Transfer data (sector 0) 45

Don t Try This at Home! https://www.youtube.com/watch?v=9emwg3fwieu &feature=youtu.be&t=30s 46

Disk Performance o I/O latency of disks L I/O = L seek + L rotate + L transfer o Disk access latency at millisecond level 47

Seek, Rotate, Transfer o Seek may take several milliseconds (ms) o Settling along can take 0.5-2ms o Entire seek often takes 4-10ms 48

Seek, Rotate, Transfer o Rotation per second (RPM) 7200 RPM is common nowadays 15000 RPM is high end Old computers may have 5400 RPM disks o 1 / 7200 RPM = 1 minute / 7200 rotations = 1 second / 120 rotations = 8.3 ms / rotation 49

Seek, Rotate, Transfer o Rotation per second (RPM) 7200 RPM is common nowadays 15000 RPM is high end Old computers may have 5400 RPM disks o 1 / 7200 RPM = 1 minute / 7200 rotations = 1 second / 120 rotations = 8.3 ms / rotation o So it may take 4.2 ms on average to rotate to target (0.5 * 8.3 ms) 50

Seek, Rotate, Transfer o Relatively fast Depends on RPM and sector density o 100+ MB/s is typical for SATA I (1.5Gb/s max) Up to 600MB/s for SATA III (6.0Gb/s) o 1s / 100MB = 10ms / MB = 4.9us/sector Assuming 512-byte sector 51

Workloads o Seeks and rotations are slow while transfer is relatively fast o What kind of workload is best suited for disks? 52

Workloads o Seeks and rotations are slow while transfer is relatively fast o What kind of workload is best suited for disks? Sequential I/O: access sectors in order (transfer dominated) o Random workloads access sectors in a random order (seek+rotation dominated) Typically slow on disks Never do random I/O unless you must! E.g., Quicksort is a terrible algorithm for disk! 53

Disk Performance Calculation o Seagate Enterprise SATA III HDD Metric Perf RPM 7200 Avg seek Max transfer 4.16ms 500MB/s o How long does an average 4KB read take? 54

Disk Performance Calculation o Seagate Enterprise SATA III HDD Metric Perf RPM 7200 Avg seek Max transfer 4.16ms 500MB/s o How long does an average 4KB read take?!"#$%&'" = * +,-.// 01 4 45 *,///,/// 7+ * +,- = 8 9% 55

Disk Performance Calculation o Seagate Enterprise SATA III HDD Metric Perf RPM 7200 Avg seek Max transfer 4.16ms 500MB/s o How long does an average 4KB read take?!"#$%&'" = * +,-.// 01 4 45 *,///,/// 7+ * +,- = 8 9% Latency = 4.16 ms + 4.2 ms + 8 us = 8.368 ms Avg Seek Avg Rotate 56

The First Commercial Disk Drive o 1956 IBM RAMDAC computer 5M (7-bit) characters 50 x 24 platters Access time <= 1 sec 57