Operating System Design Issues. I/O Management

Similar documents
I/O Management Software. Chapter 5

I/O Management Software. Chapter 5

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

Principles of Operating Systems CS 446/646

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

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

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

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

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

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

CSCI-GA Operating Systems I/O. Hubertus Franke

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

Chapter 5 Input/Output. I/O Devices

Chapter 13: I/O Systems

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

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

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

I/O Systems. Jo, Heeseung

Device-Functionality Progression

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

Last class: Today: Course administration OS definition, some history. Background on Computer Architecture

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

Virtual Memory. 1 Administrivia. Tom Kelliher, CS 240. May. 1, Announcements. Homework, toolboxes due Friday. Assignment.

Introduction to Operating Systems. Chapter Chapter

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

Lecture 15: I/O Devices & Drivers

Introduction to Operating Systems. Chapter Chapter

Chapter 9: Virtual Memory. Operating System Concepts 9 th Edition

Module 11: I/O Systems

Virtual Memory COMPSCI 386

Organisasi Sistem Komputer

CMPS 111 Spring 2003 Midterm Exam May 8, Name: ID:

Introduction to Operating. Chapter Chapter

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

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

Lecture 2: September 9

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 Disks. Protection & Security

Chapter 9: Virtual Memory

Ausgewählte Betriebssysteme - Mark Russinovich & David Solomon (used with permission of authors)

Operating Systems. V. Input / Output

Operating Systems, Fall

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

Chapter 11 I/O Management and Disk Scheduling

Hardware OS & OS- Application interface

OPERATING SYSTEMS CS136

Chapter 13: I/O Systems

Chapter 13: I/O Systems

I/O Management and Disk Scheduling. Chapter 11

Misc. Third Generation Batch Multiprogramming. Fourth Generation Time Sharing. Last Time Evolution of OSs

I/O SYSTEMS. Sunu Wibirama

Module 12: I/O Systems

Chapter 13: I/O Systems

Module 1. Introduction:

I/O. Fall Tore Larsen. Including slides from Pål Halvorsen, Tore Larsen, Kai Li, and Andrew S. Tanenbaum)

I/O. Fall Tore Larsen. Including slides from Pål Halvorsen, Tore Larsen, Kai Li, and Andrew S. Tanenbaum)

Part 1: Introduction to device drivers Part 2: Overview of research on device driver reliability Part 3: Device drivers research at ERTOS

Chapter 8: Virtual Memory. Operating System Concepts Essentials 2 nd Edition

Generic Model of I/O Module Interface to CPU and Memory Interface to one or more peripherals

Chapter 12: I/O Systems

Chapter 13: I/O Systems

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

Process Scheduling Queues

Chapter 4 Memory Management

Chapter 8: Virtual Memory. Operating System Concepts

CS370 Operating Systems

CS 450 Fall xxxx Final exam solutions. 2) a. Multiprogramming is allowing the computer to run several programs simultaneously.

What Operating Systems Do An operating system is a program hardware that manages the computer provides a basis for application programs acts as an int

Module 12: I/O Systems

OPERATING SYSTEMS & Network OVERVIEW. 1: OS & Network Overview

Operating Systems (CS1022) Input/Output. Yagiz Özbek Evren

Memory management. Knut Omang Ifi/Oracle 10 Oct, 2012

I/O MANAGEMENT CATEGORIES OF I/O DEVICES 1. Slide 1. Slide 3. Controller: Three classes of devices (by usage):

QUESTION BANK UNIT I

Chapter 9: Virtual-Memory

Virtual Memory Outline

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

2 nd Half. Memory management Disk management Network and Security Virtual machine

Memory Management. Chapter 4 Memory Management. Multiprogramming with Fixed Partitions. Ideally programmers want memory that is.

OPERATING SYSTEM. Chapter 9: Virtual Memory

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

Scuola Superiore Sant Anna. I/O subsystem. Giuseppe Lipari

Sistemi in Tempo Reale

Unit 2 : Computer and Operating System Structure

Memory Management. Reading: Silberschatz chapter 9 Reading: Stallings. chapter 7 EEL 358

15: OS Scheduling and Buffering

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

Chapter 8 & Chapter 9 Main Memory & Virtual Memory

CS533 Concepts of Operating Systems. Jonathan Walpole

A Predictable RTOS. Mantis Cheng Department of Computer Science University of Victoria

Silberschatz and Galvin Chapter 12

Spring 2017 :: CSE 506. Device Programming. Nima Honarmand

I/O Management Intro. Chapter 5

Introduction. CS3026 Operating Systems Lecture 01

Operating system Dr. Shroouq J.

Input Output (IO) Management

C02: Interrupts and I/O

Swapping. Operating Systems I. Swapping. Motivation. Paging Implementation. Demand Paging. Active processes use more physical memory than system has

Tolerating Malicious Drivers in Linux. Silas Boyd-Wickizer and Nickolai Zeldovich

Chapter 13: I/O Systems

Transcription:

I/O Management Chapter 5 Operating System Design Issues Efficiency Most I/O devices slow compared to main memory (and the CPU) Use of multiprogramming allows for some processes to be waiting on I/O while another process executes Often I/O still cannot keep up with processor speed Swapping may used to bring in additional Ready processes More I/O operations Optimise I/O efficiency especially Disk & Network I/O 1 2 Operating System Design Issues The quest for generality/uniformity: Ideally, handle all I/O devices in the same way Both in the OS and in user applications Problem: Diversity of I/O devices Especially, different access methods (random access versus stream based) as well as vastly different data rates. Generality often compromises efficiency! Hide most of the details of device I/O in lower-level routines so that processes and upper levels see devices in general terms such as read, write, open, close. I/O Software Layers Layers of the I/O Software System 3 4 Interrupt Handlers Interrupt handlers are best hidden Can execute at almost any time Raise (complex) concurrency issues in the kernel Have similar problems within applications if interrupts are propagated to user-level code (via signals, upcalls). Generally, systems are structured such that drivers starting an I/O operations block until interrupts notify them of completion Example dev_read() waits on semaphore that the interrupt handler signals. Interrupt procedure does its task then unblocks driver waiting on completion Interrupt Handler Steps Steps must be performed in software upon occurrence of an interrupt Save regs not already saved by hardware interrupt mechanism (Optionally) set up context (address space) for interrupt service procedure Typically, handler runs in the context of the currently running process No expensive context switch Set up stack for interrupt service procedure Handler usually runs on the kernel stack of current process Implies handler cannot block as the unlucky current process will also be blocked might cause deadlock Ack/Mask interrupt controller, reenable other interrupts 5 6 1

Interrupt Handler Steps Run interrupt service procedure Acknowledges interrupt at device level Figures out what caused the interrupt Received a network packet, disk read finished, UART transmit queue empty If needed, it signals blocked device driver In some cases, will have woken up a higher priority blocked thread Choose newly woken thread to schedule next. Set up MMU context for process to run next Load new/original process' registers Re-enable interrupt; Start running the new process Logical position of device drivers is shown here Drivers (originally) compiled into the kernel Including OS/161 Device installers were technicians Number and types of devices rarely changed Nowadays they are dynamically loaded when needed Linux modules Typical users (device installers) can t build kernels Number and types vary greatly Even while OS is running (e.g hot-plug USB devices) Device Drivers 7 8 Device Drivers Device Driver Drivers classified into similar categories Block devices and character (stream of data) device OS defines a standard (internal) interface to the different classes of devices Device drivers job translate request through the device-independent standard interface (open, close, read, write) into appropriate sequence of commands (register manipulations) for the particular hardware Initialise the hardware at boot time, and shut it down cleanly at shutdown 9 After issuing the command to the device, the device either Completes immediately and the driver simply returns to the caller Or, device must process the request and the driver usually blocks waiting for an I/O complete interrupt. Drivers are reentrant as they can be called by another process while a process is already blocked in the driver. Reentrant: Code that can be executed by more than one thread (or CPU) at the same time Manages concurrency using synch primitives 10 Device-Independent I/O Software There is commonality between drivers of similar classes Divide I/O software into device-dependent and device-independent I/O software Device independent software includes Buffer or Buffer-cache management Managing access to dedicated devices Error reporting 11 Device-Independent I/O Software (a) Without a standard driver interface (b) With a standard driver interface 12 2

Driver Kernel Interface Major Issue is uniform interfaces to devices and kernel Uniform device interface for kernel code Allows different devices to be used the same way No need to rewrite filesystem to switch between SCSI, IDE or RAM disk Allows internal changes to device driver with fear of breaking kernel code Uniform kernel interface for device code Drivers use a defined interface to kernel services (e.g. kmalloc, install IRQ handler, etc.) Allows kernel to evolve without breaking existing drivers Together both uniform interfaces avoid a lot of programming implementing new interfaces 13 Device-Independent I/O Software (a) Uned input (b) Buffering in user space (c) Single ing in the kernel followed by copying to user space (d) Double ing in the kernel 14 No Buffering Process must read/write a device a byte/word at a time Each individual system call adds significant overhead Process must what until each I/O is complete Blocking/interrupt/waking adds to overhead. Many short runs of a process is inefficient (poor CPU cache temporal locality) User-level Buffering Process specifies a memory that incoming data is placed in until it fills Filling can be done by interrupt service routine Only a single system call, and block/wakeup per data Much more efficient 15 16 User-level Buffering Issues What happens if is paged out to disk Could lose data while is paged in Could lock in memory (needed for DMA), however many processes doing I/O reduce RAM available for paging. Can cause deadlock as RAM is limited resource Consider write case When is available for re-use? Either process must block until potential slow device drains or deal with asynchronous signals indicating drained Operating system assigns a in main memory for an I/O request Stream-oriented Used a line at time User input from a terminal is one line at a time with carriage return signaling the end of the line Output to the terminal is one line at a time 17 18 3

Block-oriented Input transfers made to Block moved to user space when needed Another block is moved into the Read ahead User process can process one block of data while next block is read in Swapping can occur since input is taking place in system memory, not user memory Operating system keeps track of assignment of system s to user processes 19 20 Speed Up Assume T is transfer time from device C is computation time to process incoming packet M is time to copy kernel to user Computation and transfer can be done in parallel Speed up with ing What happens if kernel is full, the user is swapped out, and more data is received??? We start to lose characters or drop network packets T + C C) + M 21 22 Double Buffer Use two system s instead of one A process can transfer data to or from one while the operating system empties or fills the other Double Buffer Speed Up Computation and Memory copy can be done in parallel with transfer Speed up with double ing T + C C + M ) Usually M is much less than T giving a favourable result 23 24 4

Double Buffer May be insufficient for really bursty traffic Lots of application writes between long periods of computation Long periods of application computation while receiving data Might want to read-ahead more than a single block for disk Circular Buffer More than two s are used Each individual is one unit in a circular Used when I/O operation must keep up with process 25 26 Important Note Notice that ing, double ing, and circular ing are all Bounded-Buffer Producer-Consumer Problems Is Buffering Always Good? T + C T + C C) + M C + M ) Single Double Can M be similar or greater than C or T? 27 28 Buffering in Fast Networks I/O Software Summary Networking may involve many copies Copying reduces performance Especially if copy costs are similar to or greater than computation or transfer costs Super-fast networks put significant effort into achieving zero-copy Buffering also increases latency 29 Layers of the I/O system and the main functions of each layer 30 5