Chapter 7: Mass-storage structure & I/O systems. Operating System Concepts 8 th Edition,

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

Chapter 14: Mass-Storage Systems

Tape pictures. CSE 30341: Operating Systems Principles

Module 13: Secondary-Storage

MASS-STORAGE STRUCTURE

UNIT-7. Overview of Mass Storage Structure

Overview of Mass Storage Structure

Chapter 14: Mass-Storage Systems

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

Chapter 11: Mass-Storage Systems

Chapter 13: I/O Systems

Chapter 13: I/O Systems. Chapter 13: I/O Systems. Objectives. I/O Hardware. A Typical PC Bus Structure. Device I/O Port Locations on PCs (partial)

Chapter 5: Input Output Management. Slides by: Ms. Shree Jaswal

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

Chapter 13: I/O Systems

Chapter 12: Mass-Storage

Silberschatz, et al. Topics based on Chapter 13

Chapter 12: Mass-Storage Systems

Chapter 10: Mass-Storage Systems

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

Chapter 12: I/O Systems

Chapter 13: I/O Systems

Chapter 12: I/O Systems. Operating System Concepts Essentials 8 th Edition

V. Mass Storage Systems

Chapter 13: I/O Systems

Chapter 13: I/O Systems

Chapter 10: Mass-Storage Systems

CHAPTER 12 AND 13 - MASS-STORAGE STRUCTURE & I/O- SYSTEMS

Chapter 14 Mass-Storage Structure

Chapter 13: I/O Systems

CSC Operating Systems Spring Lecture - XIX Storage and I/O - II. Tevfik Koşar. Louisiana State University.

RAID Structure. RAID Levels. RAID (cont) RAID (0 + 1) and (1 + 0) Tevfik Koşar. Hierarchical Storage Management (HSM)

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

Chapter 14: Mass-Storage Systems. Disk Structure

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

Chapter 13: Mass-Storage Systems. Disk Structure

CS3600 SYSTEMS AND NETWORKS

Module 12: I/O Systems

Device-Functionality Progression

Chapter 12: I/O Systems. I/O Hardware

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

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

Lecture 13 Input/Output (I/O) Systems (chapter 13)

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

EIDE, ATA, SATA, USB,

Chapter 13: I/O Systems

Module 12: I/O Systems

Module 13: Secondary-Storage Structure

Mass-Storage Systems. Mass-Storage Systems. Disk Attachment. Disk Attachment

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

Free Space Management

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

Chapter 10: Mass-Storage Systems

Overview of Mass Storage Structure

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

Chapter 13: I/O Systems

I/O Systems. 04/16/2007 CSCI 315 Operating Systems Design 1

Disk scheduling Disk reliability Tertiary storage Swap space management Linux swap space management

Silberschatz and Galvin Chapter 14

VIII. Input/Output Operating Systems Prof. Dr. Marc H. Scholl DBIS U KN Summer Term

CSE 4/521 Introduction to Operating Systems. Lecture 24 I/O Systems (Overview, Application I/O Interface, Kernel I/O Subsystem) Summer 2018

Chapter 13: I/O Systems

Operating Systems 2010/2011

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

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

Input/Output Systems

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

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

Mass-Storage Structure

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

CS370 Operating Systems

CS420: Operating Systems. Mass Storage Structure

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

I/O AND DEVICE HANDLING Operating Systems Design Euiseong Seo

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

CS370 Operating Systems

I/O SYSTEMS. Sunu Wibirama

Disk Scheduling. Based on the slides supporting the text

Silberschatz and Galvin Chapter 12

CS370: Operating Systems [Spring 2017] Dept. Of Computer Science, Colorado State University

CS370: Operating Systems [Fall 2018] Dept. Of Computer Science, Colorado State University

CS370: Operating Systems [Fall 2018] Dept. Of Computer Science, Colorado State University

COT 4600 Operating Systems Fall Dan C. Marinescu Office: HEC 439 B Office hours: Tu-Th 3:00-4:00 PM

CS370: System Architecture & Software [Fall 2014] Dept. Of Computer Science, Colorado State University

Mass-Storage Systems

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

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

Chapter 12: Mass-Storage

CS370 Operating Systems

Chapter 12: Mass-Storage

CS370 Operating Systems

Today: Secondary Storage! Typical Disk Parameters!

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

UNIT 4 Device Management

Operating System 1 (ECS-501)

Mass-Storage Structure

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

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

EI 338: Computer Systems Engineering (Operating Systems & Computer Architecture)

Module 11: I/O Systems

Transcription:

Chapter 7: Mass-storage structure & I/O systems, Silberschatz, Galvin and Gagne 2009

Mass-storage structure & I/O systems Overview of Mass Storage Structure Disk Structure Disk Attachment Disk Scheduling Disk Management Swap-Space Management RAID Structure Stable-Storage Implementation Tertiary Storage Devices I/O Hardware Application I/O Interface Kernel I/O Subsystem Transforming I/O Requests to Hardware Operations Streams Performance 12.2 Silberschatz, Galvin and Gagne 2009

Overview of Mass Storage Structure Magnetic disks secondary storage Drives rotate at 60 to 200 times/second Transfer rate: rate at which data flow between drive and computer Positioning time (random-access time) is time to move disk arm to desired cylinder (seek time) rotational latency: time for desired sector to rotate under the disk head Head crash: disk head making contact with the disk surface Can t repair, disk must be replaced 12.3 Silberschatz, Galvin and Gagne 2009

Overview of Mass Storage Structure Disks can be removable Drive attached to computer via I/O bus Busses EIDE, ATA, SATA, USB, Fiber Channel, SCSI EIDE: Enhanced Integrated Drive Electronics ATA: Advanced Technology Attachment SATA: Serial ATA USB: Universal Serial Bus SCSI: Small Computer System Interface Host controller in computer uses bus to talk to disk controller built into drive 12.4 Silberschatz, Galvin and Gagne 2009

Moving-head Disk Mechanism 12.5 Silberschatz, Galvin and Gagne 2009

Overview of Mass Storage Structure (Cont.) Magnetic tape: early secondary-storage medium Relatively permanent and holds large quantities of data Access time slow Random access ~1000 times slower than disk used for backup, storage of infrequently-used data Kept in spool and wound or rewound past read-write head Once data under head, transfer rates comparable to disk 20-200GB typical storage Common technologies are 4mm, 8mm, 19mm, LTO-2 and SDLT 12.6 Silberschatz, Galvin and Gagne 2009

Disk Structure Disk drives - large 1-D arrays of logical blocks(smallest unit of transfer) The 1-D array of logical blocks is mapped onto the sectors of the disk sequentially. Sector 0 is the first sector of the first track on the outermost cylinder. Mapping proceeds that track rest of tracks in cylinder then rest of cylinders Constant linear velocity(clv): density of bits per track is uniform rotation speed changes (CD,DVD) Constant angular velocity(cav): rotation speed is constant density of bits decreases from inner to outer(hard disk) 12.7 Silberschatz, Galvin and Gagne 2009

Disk Attachment Two ways of accessing disk storage: 1. Host-attached storage (via I/O ports) 2. Network-attached storage (via a remote host in a distributed file system) 12.8 Silberschatz, Galvin and Gagne 2009

Host-attached storage Through local I/O ports several technologies: Desktop PC IDE OR ATA SATA (simplified cabling) High-end workstations& servers SCSI OR FC (fiber channel) SCSI: bus architecture Ribbon cable with large no. of conductors Supports max. of 16 devices on the bus One controller card in host (SCSI initiator) & 15 storage devices (SCSI targets) 12.9 Silberschatz, Galvin and Gagne 2009

ATA & SATA cables 12.10 Silberschatz, Galvin and Gagne 2009

SCSI cables 12.11 Silberschatz, Galvin and Gagne 2009

Fiber cable: High-speed serial architecture Large address space FC-AL (attributed loop) can address 126 devices Switching nature of comm. Multiple hosts & storage devices Storage devices for host-attached storage: Hard disk drives CD DVD Tape drives 12.12 Silberschatz, Galvin and Gagne 2009

Network-Attached Storage (NAS) made available over a network rather than over a local connection (such as a bus) NFS and CIFS are common protocols Implemented via remote procedure calls (RPCs) between host and storage Less efficient & lower performance New ISCSI protocol uses IP network to carry the SCSI protocol 12.13 Silberschatz, Galvin and Gagne 2009

Storage Area Network Common in large storage environments (and becoming more common) Multiple hosts attached to multiple storage arrays flexible FC most common SAN interconnect InfiniBand special purpose bus, provides h/w & s/w support 12.14 Silberschatz, Galvin and Gagne 2009

OS h/w efficiently Disk Scheduling disk drives fast access time & large disk bandwidth Disk bandwidth is the total number of bytes transferred, divided by the total time between the first request for service and the completion of the last transfer. Access time has two major components: Seek time (Minimize seek time( seek distance) Rotational latency 12.15 Silberschatz, Galvin and Gagne 2009

Disk Scheduling (Cont.) Several algorithms exist to schedule the servicing of disk I/O requests. We illustrate them with a request queue (0-199). 98, 183, 37, 122, 14, 124, 65, 67 Head pointer 53 12.16 Silberschatz, Galvin and Gagne 2009

FCFS scheduling Illustration shows total head movement of 640 cylinders. 12.17 Silberschatz, Galvin and Gagne 2009

SSTF scheduling SSTF : shortest-seek-time-first Selects the request with the minimum seek time from the current head position. SSTF scheduling is a form of SJF scheduling; may cause starvation of some requests. Illustration shows total head movement of 236 cylinders. 12.18 Silberschatz, Galvin and Gagne 2009

SSTF (Cont.) 12.19 Silberschatz, Galvin and Gagne 2009

SCAN The disk arm starts at one end of the disk, and moves toward the other end, servicing requests until it gets to the other end of the disk, where the head movement is reversed and servicing continues. Sometimes called the elevator algorithm. Illustration shows total head movement of 208 cylinders. 12.20 Silberschatz, Galvin and Gagne 2009

SCAN (Cont.) 12.21 Silberschatz, Galvin and Gagne 2009

C-SCAN Provides a more uniform wait time than SCAN. The head moves from one end of the disk to the other. servicing requests as it goes. When it reaches the other end, however, it immediately returns to the beginning of the disk, without servicing any requests on the return trip. Treats the cylinders as a circular list that wraps around from the last cylinder to the first one. 12.22 Silberschatz, Galvin and Gagne 2009

C-SCAN (Cont.) 12.23 Silberschatz, Galvin and Gagne 2009

Version of C-SCAN LOOK scheduling Arm only goes as far as the last request in each direction, then reverses direction immediately, without first going all the way to the end of the disk. 12.24 Silberschatz, Galvin and Gagne 2009

C-LOOK (Cont.) 12.25 Silberschatz, Galvin and Gagne 2009

Selecting a Disk-Scheduling Algorithm SSTF common SCAN and C-SCAN better for systems that place a heavy load on the disk. Performance depends on the number and types of requests. Requests for disk service can be influenced by the fileallocation method. The disk-scheduling algorithm should be written as a separate module of the OS, allowing replacement if necessary. SSTF or LOOK --reasonable choice of default algorithm. 12.26 Silberschatz, Galvin and Gagne 2009

Disk formatting: Disk Management Low-level formatting (physical formatting) Dividing a disk into sectors that the disk controller can read and write. To use a disk to hold files, Partition the disk into one or more groups of cylinders. Logical formatting or making a file system. Boot block: initializes system. The bootstrap is stored in ROM. Bootstrap loader program. Boot disk or system disk. 12.27 Silberschatz, Galvin and Gagne 2009

Booting from a Disk in Windows 2000 12.28 Silberschatz, Galvin and Gagne 2009

Bad blocks: Disk Management Disks with IDE controllers-handle manually MS-DOS format (cmd) logical formatting(scans to find bad blocks) SCSI disks: FAT entry - special value - not to use that block Controller list of bad blocks List initialized during low level formatting Updated over the life of the disk Sector sparing (forwarding) to handle bad blocks. Sector slipping 12.29 Silberschatz, Galvin and Gagne 2009

Swap-Space Management Swap-space Virtual memory uses disk space as an extension of main memory. Swap-space can be carved out of the normal file system or, more commonly, it can be in a separate disk partition. Swap-space management 4.3BSD allocates swap space when process starts; holds text segment (the program) and data segment. Kernel uses swap maps to track swap-space use. Swap map array of integer counters, each corresponding to a page slot Counter =0 page slot available >0 occupied by a swapped page Solaris 2 allocates swap space only when a page is forced out of physical memory 12.30 Silberschatz, Galvin and Gagne 2009

Data Structures for Swapping on Linux Systems 12.31 Silberschatz, Galvin and Gagne 2009

RAID Structure RAID Redundant Array of Inexpensive (independent) disks Addresses performance and reliability issues Improvement of reliability via redundancy: Mirroring: duplicate every disk Power failures: write to 2 disks if power fails data is inconsistent in both Sol: 1. write one copy first, then next 2. NVRAM cache to RAID array Improvement in performance via parallelism: Striping data across disks improves transfer rate Data striping: splitting bits of each byte across multiple disks (bit-level striping) Block-level striping: blocks of a file are striped across multiple disks (most common) 12.32 Silberschatz, Galvin and Gagne 2009

RAID Levels Mirroring Striping Advantage High reliability High data transfer rates Disadvantage Expensive Does not improve reliability RAID levels: redundancy at lower costs using data striping combined with parity bits. RAID level0: disk arrays with striping at the level of blocks Without redundancy RAID 0: non-redundant striping 12.33 Silberschatz, Galvin and Gagne 2009

RAID Level 1: Refers to disk mirroring RAID Levels C C C C RAID Level 2: RAID 1: mirrored disks also known as memory-style error-correcting-code (ECC) RAID 2: memory-style error correcting codes organization Uses parity, single errors are detected Uses only 3 disks overhead for 4 disks of data P P P 12.34 Silberschatz, Galvin and Gagne 2009

RAID Levels RAID Level 3: Bit-interleaved parity organization Single parity bit for error detection & correction Bit in a sector got damaged-find whether it is 1 or 0? Compute parity of corresponding bits from other disks =stored parity missing bit is 0, otherwise 1 Only one parity disk for several regular disks High transfer rate Supports fewer I/Os per second RAID 3: bit-interleaved parity P 12.35 Silberschatz, Galvin and Gagne 2009

RAID Level 4: RAID Levels Block-interleaved parity organization Uses block level striping Keeps a parity block on a separate disk for corresponding blocks from N other disks RAID Level 5: RAID 4: block-interleaved parity Block-interleaved distributed parity Differs from level 4 by spreading data & parity among all N+1 disks P P P P P P RAID 5: block-interleaved distributed parity 12.36 Silberschatz, Galvin and Gagne 2009

RAID Levels RAID Level 6: P+Q redundancy scheme Stores extra redundant information to guard against multiple disk failures Reed-Solomon codes (error-correcting codes) are used 2 bits of redundant data are stored for every 4 bits of data System can tolerate two disk failures P P P P P P P P RAID 6: P+Q redundancy P P 12.37 Silberschatz, Galvin and Gagne 2009

RAID Levels 12.38 Silberschatz, Galvin and Gagne 2009

RAID Levels RAID Level 0+1: Refers to a combination of levels 0 (performance) & 1 (reliability) Doubles number of disks needed for storage More expensive 12.39 Silberschatz, Galvin and Gagne 2009

RAID Level 1+0: RAID Levels Disks are mirrored in pairs, then resulting mirror pairs are stripped 12.40 Silberschatz, Galvin and Gagne 2009

RAID (0 + 1) and (1 + 0) 12.41 Silberschatz, Galvin and Gagne 2009

Selecting a RAID level RAID level 0: high-performance applications RAID level 1: rebuilding of data is easy RAID level 5: preferred for storing large volumes of data RAID level 0+1 & 1+0: where both performance & reliability are important 12.42 Silberschatz, Galvin and Gagne 2009

Stable-Storage Implementation Stable storage: information is never lost To implement stable storage: Replicate information on more than one nonvolatile storage media with independent failure modes. Update information in a controlled manner to ensure that we can recover the stable data after any failure during data transfer or recovery. 12.43 Silberschatz, Galvin and Gagne 2009

Stable-Storage Implementation Output operation: (2 physical blocks for each logical block) Write to first physical block First write successful write same inf. onto second block Declare operation complete only after second write successful Recovery from a failure: Each block is examined, same & no detectable errors no action If one block has detectable error replace with contents of other block If neither block has error, but contents differ replace first block with second 12.44 Silberschatz, Galvin and Gagne 2009

Tertiary Storage Devices Low cost is the defining characteristic of tertiary storage. Generally, tertiary storage is built using removable media Ex. of removable media: floppy disks, tapes, CDs, DVDs 12.45 Silberschatz, Galvin and Gagne 2009

Removable Disks Floppy disk: thin flexible disk coated with magnetic material, enclosed in a protective plastic case. Most floppies hold about 1 MB; magnetic disks - as fast as hard disks, but they are at a greater risk of damage from exposure. 12.46 Silberschatz, Galvin and Gagne 2009

Magneto-optic disk: Removable Disks (Cont.) records data on a rigid platter coated with magnetic material, covered with a protective layer of plastic or glass; resistant to head crashes Laser heat is used to amplify a large, weak magnetic field to record a bit. Laser light is also used to read data (Kerr effect). 12.47 Silberschatz, Galvin and Gagne 2009

Removable Disks (Cont.) Optical disk: Do not use magnetism Special materials that can be altered by laser light 12.48 Silberschatz, Galvin and Gagne 2009

WORM disks: Removable Disks read-write disks: modified over and over. WORM (Write Once, Read Many Times) disks: written only once. Thin aluminum film sandwiched between two glass or plastic platters. To write a bit, the drive uses a laser light to burn a small hole through the aluminum; information can be destroyed but not altered. Very durable and reliable. Read-only disks: CD & DVD, come from the factory with the data pre-recorded. 12.49 Silberschatz, Galvin and Gagne 2009

Less expensive Holds more data Random access is much slower Tapes Economic for backup copies of disk data Large tape installations typically use robotic tape changers that move tapes between tape drives and storage slots in a tape library. stacker library that holds a few tapes silo library that holds thousands of tapes A disk-resident file can be archived to tape for low cost storage; the computer can stage it back into disk storage for active use. 12.50 Silberschatz, Galvin and Gagne 2009

Operating System Issues Major OS jobs: manage physical devices & to present a virtual machine abstraction to applications For hard disks, the OS provides two abstraction: Raw device an array of data blocks. File system the OS queues and schedules the interleaved requests from several applications. 12.51 Silberschatz, Galvin and Gagne 2009

Application Interface Tapes are presented as a raw storage medium, i.e., application does not open a file on the tape, it opens the whole tape drive as a raw device. Usually the tape drive is reserved for the exclusive use of that application. application must decide how to use the array of blocks. Since every application makes up its own rules for how to organize a tape, a tape full of data can generally only be used by the program that created it. 12.52 Silberschatz, Galvin and Gagne 2009

Tape Drives Basic operations differ from disk drive. locate(): positions the tape to a specific logical block, not an entire track (corresponds to seek). read position(): operation returns the logical block number where the tape head is. space(): operation enables relative motion. Tape drives are append-only devices; updating a block in the middle of the tape also effectively erases everything beyond that block. An EOT mark is placed after a block that is written. 12.53 Silberschatz, Galvin and Gagne 2009

File Naming difficult when we want to write data on a removable cartridge on one computer, and then use the cartridge in another computer. name space problem - depends on applications and users to figure out how to access and interpret the data. removable media (e.g., CDs) are so well standardized that all computers use them the same way. 12.54 Silberschatz, Galvin and Gagne 2009

Hierarchical Storage Management (HSM) Extends the storage hierarchy beyond primary & secondary storage to incorporate tertiary storage. Usually implemented as a jukebox of tapes or removable disks. Usually incorporate tertiary storage by extending the file system. Small and frequently used files remain on disk. Large, old, inactive files are archived to the jukebox. found in supercomputing centers and other large installations that have enormous volumes of data. 12.55 Silberschatz, Galvin and Gagne 2009

Performance issues Three most important aspects of tertiary storage performance: 1. Speed 2. Reliability 3. Cost 12.56 Silberschatz, Galvin and Gagne 2009

1. Speed: Performance issues Two aspects of speed: bandwidth and latency. Bandwidth is measured in bytes per second. Sustained bandwidth average data rate during a large transfer; i.e., No. of bytes/transfer time Data rate when the data stream is actually flowing. Effective bandwidth average over the entire I/O time, including seek or locate, and cartridge switching. Drive s overall data rate. 12.57 Silberschatz, Galvin and Gagne 2009

1. Speed: Performance issues Access latency amount of time needed to locate data. Access time for a disk move the arm to the selected cylinder and wait for the rotational latency; < 35 milliseconds. Access on tape - winding the tape reels until the selected block reaches the tape head; tens or hundreds of seconds. random access- tape is about a thousand times slower than on disk. removable library -storage of infrequently used data, library can only satisfy a relatively small number of I/O requests per hour 12.58 Silberschatz, Galvin and Gagne 2009

2. Reliability: Performance issues Good performance high speed & reliability A fixed disk drive is likely to be more reliable than a removable disk or tape drive. head crash -fixed hard disk - destroys the data failure of a tape/optical disk drive - leaves the data cartridge unharmed An optical cartridge is likely to be more reliable than a magnetic disk or tape. 12.59 Silberschatz, Galvin and Gagne 2009

3. Cost: Performance issues Main memory is much more expensive than disk storage The cost per megabyte of hard disk storage is competitive with magnetic tape if only one tape is used per drive. The cheapest tape drives and the cheapest disk drives have had about the same storage capacity over the years. Tertiary storage gives a cost savings only when the number of cartridges is considerably larger than the number of drives. 12.60 Silberschatz, Galvin and Gagne 2009

Price per Megabyte of DRAM, From 1981 to 2004 12.61 Silberschatz, Galvin and Gagne 2009

Price per Megabyte of Magnetic Hard Disk, From 1981 to 2004 12.62 Silberschatz, Galvin and Gagne 2009

Price per Megabyte of a Tape Drive, From 1984-2000 12.63 Silberschatz, Galvin and Gagne 2009

I/O Systems, Silberschatz, Galvin and Gagne 2009

I/O Systems I/O Hardware Application I/O Interface Kernel I/O Subsystem Transforming I/O Requests to Hardware Operations Streams Performance 12.65 Silberschatz, Galvin and Gagne 2009

I/O Hardware Incredible variety of I/O devices Common concepts: Port (connection-point) Bus (daisy chain or shared direct access) Controller (host adapter) : collection of electronics that can operate on a port, bus or device PCI bus: Peripheral Component Interconnect bus Connects processor-memory subsystem to the fast devices Expansion bus: connects relatively slow devices (keyboard) Devices have addresses, used by Direct I/O instructions Memory-mapped I/O 12.66 Silberschatz, Galvin and Gagne 2009

A Typical PC Bus Structure 12.67 Silberschatz, Galvin and Gagne 2009

Device I/O port locations on PCs (partial) 12.68 Silberschatz, Galvin and Gagne 2009

I/O port: 4 registers I/O Hardware 1. data-in: read by the host to get input 2. data-out: written by the host to send output 3. status: bits read by the host, whether current command has completed or not etc. 4. control: written by host to start a command or to change the mode of a device Full duplex/half duplex Parity checking 12.69 Silberschatz, Galvin and Gagne 2009

Polling Determines state of device command-ready busy Error Busy-waiting or polling cycle to wait for I/O from device 12.70 Silberschatz, Galvin and Gagne 2009

Interrupts CPU Interrupt-request line triggered by I/O device Interrupt handler receives interrupts Maskable to ignore or delay some interrupts Interrupt vector to dispatch interrupt to correct handler Based on priority Some nonmaskable Interrupt mechanism also used for exceptions 12.71 Silberschatz, Galvin and Gagne 2009

Interrupt-Driven I/O Cycle 12.72 Silberschatz, Galvin and Gagne 2009

Intel Pentium Processor Event-Vector Table 12.73 Silberschatz, Galvin and Gagne 2009

Direct Memory Access Used to avoid programmed I/O for large data movement Requires DMA controller Bypasses CPU to transfer data directly between I/O device and memory 12.74 Silberschatz, Galvin and Gagne 2009

Six Step Process to Perform DMA Transfer 12.75 Silberschatz, Galvin and Gagne 2009

Application I/O Interface Device-driver layer hides differences among I/O controllers from kernel Devices vary in many dimensions Character-stream or block Sequential or random-access Sharable or dedicated Speed of operation read-write, read only, or write only 12.76 Silberschatz, Galvin and Gagne 2009

A Kernel I/O Structure 12.77 Silberschatz, Galvin and Gagne 2009

Characteristics of I/O Devices 12.78 Silberschatz, Galvin and Gagne 2009

Block and Character Devices Block devices include disk drives Commands include read(), write(), seek() Raw I/O (block device as a linear array of blocks) or filesystem access Memory-mapped file access possible Character devices include keyboards, mice, serial ports Commands include get(), put() Libraries layered on top allow line editing 12.79 Silberschatz, Galvin and Gagne 2009

Network Devices Varying enough from block and character to have own interface Unix and Windows NT/9x/2000 include socket interface Separates network protocol from network operation Includes select() functionality (eliminates polling & busy waiting) Approaches vary widely (pipes, FIFOs, streams, queues, mailboxes) 12.80 Silberschatz, Galvin and Gagne 2009

Clocks and Timers Provide three basic functions: give the current time, give the elapsed time, Set a timer to trigger operation X at time T Programmable interval timer used for timings, periodic interrupts 12.81 Silberschatz, Galvin and Gagne 2009

Blocking and Nonblocking I/O Blocking - process suspended until I/O completed Easy to use and understand Insufficient for some needs Nonblocking - I/O call returns as much as available User interface, data copy (buffered I/O) Implemented via multi-threading Returns quickly with count of bytes read or written Asynchronous - process runs while I/O executes Difficult to use I/O subsystem signals process when I/O completed 12.82 Silberschatz, Galvin and Gagne 2009

Two I/O Methods Synchronous Asynchronous Synchronous Asynchronous 12.83 Silberschatz, Galvin and Gagne 2009

I/O Scheduling: Kernel I/O Subsystem Some I/O request ordering via per-device queue Some OSs try fairness Device-status table: contains an entry for each I/O device (managed by kernel) I/O subsystem improves efficiency by: Scheduling I/O operations Buffering or caching 12.84 Silberschatz, Galvin and Gagne 2009

Device-status Table 12.85 Silberschatz, Galvin and Gagne 2009

Buffering: Kernel I/O Subsystem storing data in memory while transferring between devices Done for 3 reasons: 1. To cope with device speed mismatch 2. To cope with device data-transfer size mismatch 3. To maintain copy semantics (kernel buffers & application buffers) 12.86 Silberschatz, Galvin and Gagne 2009

Sun Enterprise 6000 Device-Transfer Rates 12.87 Silberschatz, Galvin and Gagne 2009

Kernel I/O Subsystem Caching - fast memory holding copy of data Always just a copy Key to performance Buffer: may hold only existing copy of data item Cache: holds a copy on faster storage of data item that resides elsewhere Spooling buffer that holds output for a device If device can serve only one request at a time i.e., Printing Coordinate concurrent output 12.88 Silberschatz, Galvin and Gagne 2009

Kernel I/O Subsystem Device Reservation: (concurrent device access) provides exclusive access to a device System calls for allocation and deallocation Watch out for deadlock 12.89 Silberschatz, Galvin and Gagne 2009

Error Handling: Kernel I/O Subsystem OS can recover from disk read, device unavailable, transient write failures Most return an error number or code when I/O request fails System error logs hold problem reports Ex: failure of SCSI device is reported by SCSI protocol in 3 levels: 1. Sense key: general nature of failure (h/w error or illegal request) 2. Additional sense code: category of failure (bad command or self-test failure) 3. Additional sense-code qualifier: even more detail (which command or which h/w subsystem failed) 12.90 Silberschatz, Galvin and Gagne 2009

I/O Protection: Kernel I/O Subsystem User process may accidentally or purposefully attempt to disrupt normal operation via illegal I/O instructions All I/O instructions defined to be privileged I/O must be performed via system calls Memory-mapped and I/O port memory locations must be protected too 12.91 Silberschatz, Galvin and Gagne 2009

Use of a System Call to Perform I/O 12.92 Silberschatz, Galvin and Gagne 2009

Kernel I/O Subsystem Kernel Data Structures: Kernel keeps state inf. for I/O components, including open file tables, network connections, character device state Many complex data structures to track buffers, memory allocation, dirty blocks Some use object-oriented methods and message passing to implement I/O 12.93 Silberschatz, Galvin and Gagne 2009

UNIX I/O Kernel Structure 12.94 Silberschatz, Galvin and Gagne 2009

Transforming I/O Requests to Hardware Operations Consider reading a file from disk for a process: Determine device holding file Translate name to device representation Physically read data from disk into buffer Make data available to requesting process Return control to process 12.95 Silberschatz, Galvin and Gagne 2009

Life Cycle of An I/O Request 12.96 Silberschatz, Galvin and Gagne 2009

STREAMS STREAM a full-duplex communication channel between a userlevel process and a device (in Unix System V and beyond) A STREAM consists of: - STREAM head interfaces with the user process - driver end interfaces with the device - zero or more STREAM modules between them. Each module contains a read queue and a write queue Message passing is used to communicate between queues 12.97 Silberschatz, Galvin and Gagne 2009

The STREAMS Structure 12.98 Silberschatz, Galvin and Gagne 2009

Performance I/O is a major factor in system performance: Demands CPU to execute device driver, kernel I/O code Context switches due to interrupts Data copying Network traffic especially stressful 12.99 Silberschatz, Galvin and Gagne 2009

Intercomputer Communications 12.100 Silberschatz, Galvin and Gagne 2009

Improving Performance Reduce number of context switches Reduce data copying Reduce interrupts by using large transfers, smart controllers, polling Use DMA Balance CPU, memory, bus, and I/O performance for highest throughput 12.101 Silberschatz, Galvin and Gagne 2009

Device-Functionality Progression 12.102 Silberschatz, Galvin and Gagne 2009

End of Chapter 7, Silberschatz, Galvin and Gagne 2009