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

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

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

Bus Architecture Example

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

OPERATING SYSTEMS CS3502 Spring Input/Output System Chapter 9

OPERATING SYSTEMS CS3502 Spring Input/Output System Chapter 9

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

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

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

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

CS429: Computer Organization and Architecture

CS429: Computer Organization and Architecture

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

CSE506: Operating Systems CSE 506: Operating Systems

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

Operating Systems Peter Pietzuch

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

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

I/O Systems and Storage Devices

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

Disk Scheduling COMPSCI 386

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

CSE 451: Operating Systems Spring Module 12 Secondary Storage

CSE 153 Design of Operating Systems Fall 2018

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

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

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

I/O. Disclaimer: some slides are adopted from book authors slides with permission 1

Lecture 16: Storage Devices

Mass Storage. 2. What are the difference between Primary storage and secondary storage devices? Primary Storage is Devices. Secondary Storage devices

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

FFS: The Fast File System -and- The Magical World of SSDs

CSCI 350 Ch. 12 Storage Device. Mark Redekopp Michael Shindler & Ramesh Govindan

Hard Disk Drives (HDDs)

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

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

CSE 153 Design of Operating Systems

CSCI-GA Database Systems Lecture 8: Physical Schema: Storage

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

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

Secondary Storage Management Rab Nawaz Jadoon

Department of Computer Engineering University of California at Santa Cruz. File Systems. Hai Tao

ECE 550D Fundamentals of Computer Systems and Engineering. Fall 2017

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

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

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

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

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

Mass-Storage Structure

UNIT 4 Device Management

Disc Allocation and Disc Arm Scheduling?

Lecture 18: Memory Systems. Spring 2018 Jason Tang

Block Device Scheduling. Don Porter CSE 506

Block Device Scheduling

Today: Secondary Storage! Typical Disk Parameters!

Disks, Memories & Buffer Management

Disk Scheduling. Based on the slides supporting the text

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

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

Mass-Storage Structure

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

Chapter 14: Mass-Storage Systems. Disk Structure

CS420: Operating Systems. Mass Storage Structure

CS 261 Fall Mike Lam, Professor. Memory

Storage. CS 3410 Computer System Organization & Programming

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

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2017 Lecture 13

I/O Devices & SSD. Dongkun Shin, SKKU

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

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

Input Output (IO) Management

Where Have We Been? Ch. 6 Memory Technology

STORING DATA: DISK AND FILES

EECS 482 Introduction to Operating Systems

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

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

Chapter 13: Mass-Storage Systems. Disk Structure

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?

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

Free Space Management

Block Device Scheduling. Don Porter CSE 506

Storage Technologies and the Memory Hierarchy

L7: Performance. Frans Kaashoek Spring 2013

Computer Fundamentals and Operating System Theory. By Neil Bloomberg Spring 2017

Administrivia. Midterm. Realistic PC architecture. Memory and I/O buses. What is memory? What is I/O bus? E.g., PCI

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

Chapter 10: Mass-Storage Systems

Flash memory talk Felton Linux Group 27 August 2016 Jim Warner

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

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

Module 13: Secondary-Storage Structure

Questions on Midterm. Midterm. Administrivia. Memory and I/O buses. Realistic PC architecture. What is memory? Median: 59.5, Mean: 57.3, Stdev: 26.

Computer Organization: A Programmer's Perspective

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

Mass-Storage. ICS332 Operating Systems

Operating Systems. V. Input / Output. Eurecom

Chapter 11. I/O Management and Disk Scheduling

Disks. Storage Technology. Vera Goebel Thomas Plagemann. Department of Informatics University of Oslo

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

Chapter 5. Large and Fast: Exploiting Memory Hierarchy

Transcription:

I/O 1 Devices and I/O key concepts device registers, device drivers, program-controlled I/O, DMA, polling, disk drives, disk head scheduling reading Three Easy Pieces: Chapters 36-37

I/O 2 Sys/161 Device Examples timer/clock - current time, timer, beep disk drive - persistent storage serial console - character input/output text screen - character-oriented graphics network interface - packet input/output

I/O 3 Device Register Example: Sys/161 timer/clock Offset Size Type Description 0 4 status current time (seconds) 4 4 status current time (nanoseconds) 8 4 command restart-on-expiry 12 4 status and command interrupt (reading clears) 16 4 status and command countdown time (microseconds) 20 4 command speaker (causes beeps)

I/O 4 Device Register Example: Serial Console Offset Size Type Description 0 4 command and data character buffer 4 4 status writeirq 8 4 status readirq

I/O 5 Device Drivers a device driver is a part of the kernel that interacts with a device example: write character to serial output device // only one writer at a time P(output device write semaphore) // trigger the write operation write character to device data register repeat { read writeirq register } until status is completed // make the device ready again write writeirq register to ack completion V(output device write semaphore) this example illustrates polling: the kernel driver repeatedly checks device status

I/O 6 Using Interrupts to Avoid Polling Device Driver Write Handler: // only one writer at a time P(output device write semaphore) // trigger write operation write character to device data register Interrupt Handler for Serial Device: // make the device ready again write writeirq register to ack completion V(output device write semaphore)

I/O 7 Accessing Devices how can a device driver access device registers? Option 1: special I/O instructions such asin andout instructions on x86 device registers are assigned port numbers instructions transfer data between a specified port and a CPU register Option 2: memory-mapped I/O each device register has a physical memory address device drivers can read from or write to device registers using normal load and store instructions, as though accessing memory

I/O 8 MIPS/OS161 Physical Address Space 0x00000000 RAM 0xffffffff ROM: 0x1fc00000 0x1fdfffff devices: 0x1fe00000 0x1fffffff 0x1fe00000 64 KB device "slot" 0x1fffffff Each device is assigned to one of 32 64KB device slots. A device s registers and data buffers are memory-mapped into its assigned slot.

I/O 9 Logical View of a Disk Drive disk is an array of numbered blocks (or sectors) each block is the same size (e.g., 512 bytes) blocks are the unit of transfer between the disk and memory typically, one or more contiguous blocks can be transferred in a single operation storage is non-volatile, i.e., data persists even when the device is without power

I/O 10 A Disk Platter s Surface rotation seek 38 39 15 6 14 28 7 1 29 8 2 9 30 tracks 31 37 36 5 13 4 12 11 3 10 32 arm 35 34 33 sectors read/write head

I/O 11 moving data to/from a disk involves: Cost Model for Disk I/O seek time: move the read/write heads to the appropriate cylinder depends on distance (in tracks) between previous request and current request - called the seek distance rotational latency: wait until the desired sectors spin to the read/write heads depends on the rotational speed of the disk transfer time: wait while the desired sectors spin past the read/write heads depends on the rotational speed of the disk and the amount of data being read/written request service time is the sum of seek time, rotational latency, and transfer time

I/O 12 Seek time: Seek, Rotation, and Transfer If the next request is for data on the same track as the previous request, seek distance and seek time will be zero. In the worst case, e.g., seek from outermost track to innermost track, seek time may be 10 milliseconds or more. Rotational Latency: Consider a disk that spins at 12,000 RPM One complete rotation takes 5 millseconds. Rotational latency ranges from 0ms to 5ms. Transfer Time: Once positioned, the 12,000 RPM disk can read/write all data on a track in one rotation (5ms) If only X% of the track s sectors are being read/written, transfer time will be X% of the complete rotation time (5ms).

I/O 13 Performance Implications of Disk Characteristics larger transfers to/from a disk device are more efficient than smaller ones. That is, the cost (time) per byte is smaller for larger transfers. (Why?) sequential I/O is faster than non-sequential I/O sequential I/O operations eliminate the need for (most) seeks

I/O 14 Disk Head Scheduling goal: reduce seek times by controlling the order in which requests are serviced disk head scheduling may be performed by the device, by the operating system, or both for disk head scheduling to be effective, there must be a queue of outstanding disk requests (otherwise there is nothing to reorder) an on-line approach is required: new I/O requests may arrive at any time

I/O 15 FCFS Disk Head Scheduling handle requests in the order in which they arrive fair and simple, but no optimization of seek times 1 50 100 150 200 head 14 37 53 65 70 104 122 130 183 arrival order: 104 183 37 122 14 130 65 70

I/O 16 Shortest Seek Time First (SSTF) choose closest request (a greedy approach) seek times are reduced, but requests may starve 1 50 100 150 200 head 14 37 53 65 70 104 122 130 183 arrival order: 104 183 37 122 14 130 65 70

I/O 17 Elevator Algorithms (SCAN) Under SCAN, aka the elevator algorithm, the disk head moves in one direction until there are no more requests in front of it, then reverses direction. there are many variations on this idea SCAN reduces seek times (relative to FCFS), while avoiding starvation

I/O 18 SCAN Example 1 50 100 150 200 head 14 37 53 65 70 104 122 130 183 arrival order: 104 183 37 122 14 130 65 70

I/O 19 Data Transfer To/From Devices Option 1: program-controlled I/O The device driver moves the data between memory and a buffer on the device. Simple, but the CPU is busy while the data is being transferred. Option 2: direct memory access (DMA) The device itself is responsible for moving data to/from memory. CPU is not busy during this data transfer, and is free to do something else. Sys/161 disks do program-controlled I/O.

I/O 20 Device Register Example: Sys/161 disk controller Offset Size Type Description 0 4 status number of sectors 4 4 status and command status 8 4 command sector number 12 4 status rotational speed (RPM) 32768 512 data transfer buffer

I/O 21 Writing to a Sys/161 Disk Device Driver Write Handler: // only one disk request at a time P(disk semaphore) copy data from memory to device transfer buffer write target sector number to disk sector number register write write command to disk status register // wait for request to complete P(disk completion semaphore) V(disk semaphore) Interrupt Handler for Disk Device // make the device ready again write disk status register to ack completion V(disk completion semaphore)

I/O 22 Reading From a Sys/161 Disk Device Driver Read Handler: // only one disk request at a time P(disk semaphore) write target sector number to disk sector number register write read command to disk status register // wait for request to complete P(disk completion semaphore) copy data from device transfer buffer to memory V(disk semaphore) Interrupt Handler for Disk Device // make the device ready again write disk status register to ack completion V(disk completion semaphore)

I/O 23 Direct Memory Access (DMA) DMA is used for block data transfers between devices (e.g., a disk) and memory Under DMA, the CPU initiates the data transfer and is notified when the transfer is finished. However, the device (not the CPU) controls the transfer itself. CPU 1 3 2 memory disk 1. CPU issues DMA request to device 2. device directs data transfer 3. device interrupts CPU on completion

I/O 24 Solid State Drives(SSD) no mechanical parts; use integrated circuits for persistant storage instead of magnetic surfaces DRAM: requires constant power to keep values transistors with capacitors capacitor holds microsecond charge; periodically refreshed by primary power Flash Memory: traps electrons in quantum cage floating gate transistors usually NAND (not-and gates)

I/O 25 SSD Data Arrangement logically divided into blocks and pages 2, 4 or 8KB pages 32KB-4MB blocks reads/writes at page level pages are initialized to 1s; can transition 1 0 at page level (i.e., write new page) a high voltage is required to switch 0 1 (i.e., overwrite/delete page) cannot apply high voltage at page level, only to blocks overwriting/deleting data must be done at the block level

I/O 26 Writing and Deleting from Flash Memory Naive Solution (slow): read whole block into memory re-initialize block (all page bits back to 1s) update block in memory; write back to SSD SSD controller handles requests (faster): mark page to be deleted/overwritten as invalid write to an unused page update translation table requires garbage collection

I/O 27 SSDs are not impervious Wear Leveling blocks have limited number of write cycles if block is no longer writeable; it becomes ready-only when a certain % of blocks are read-only; disk becomes read-only SSD controller wear-levels; ensuring that write cycles are evenly spread across all blocks

I/O 28 Defragmentation defragmentation takes files spread across multiple, non-sequential pages and makes them sequential it re-writes many pages of memory, possibly several times SSD random and sequential access have approximately the same cost no clear advantage to defragmenting extra, unnecessary writes performed by defragmenting causes pre-mature disk aging