CSC501 Operating Systems Principles. I/O Devices

Similar documents
Have both hardware and software. Want to hide the details from the programmer (user).

1. Computer System Structure and Components

CS 3530 Operating Systems. L02 OS Intro Part 1 Dr. Ken Hoganson

CSC 2405: Computer Systems II

I/O Device and Drivers

Chapter 11 I/O Management and Disk Scheduling

Devices and Device Controllers

Introduction. What is an Operating System?

Operating Systems. Lecture 03. February 11, 2013

COS 318: Operating Systems. I/O Device and Drivers. Input and Output. Definitions and General Method. Revisit Hardware

Operating Systems 4 th Class

Linux Driver Devices. Why, When, Which, How?

Lesson Objectives. To provide a grand tour of the major operating systems components To provide coverage of basic computer system organization

Computer-System Architecture

Computer Organization & Architecture Lecture #19

Device Management Functions

CS161: Operating Systems

I/O. Input/Output. Types of devices. Interface. Computer hardware

Chapter 3: Operating-System Structures. System Components Operating System Services System Calls System Programs System Structure Virtual Machines

Storage. The text highlighted in green in these slides contain external hyperlinks. 1 / 14

Introduction to Operating Systems. Perspective of the Computer. System Software. Indiana University Chen Yu

Chapter 6, The Operating System Machine Level

OPERATING SYSTEM SERVICES

Chapter 1 Computer System Overview

Operating System Components

Computer Systems Structure Input/Output

POSIX. RTOSes Part I. POSIX Versions. POSIX Versions (2)

Chapter 2: OS Overview

Chapter 11: Input/Output Organisation. Lesson 06: Programmed IO

Input / Output and I/O Strategies

Lecture 6: Interrupts. CSC 469H1F Fall 2006 Angela Demke Brown

How to design and implement firmware for embedded systems

Lecture 1 Operating System Overview

REAL TIME OPERATING SYSTEM PROGRAMMING-II: II: Windows CE, OSEK and Real time Linux. Lesson-12: Real Time Linux

Linux Process Scheduling Policy

11: I/O Device Management

Objectives. Chapter 2: Operating-System Structures. Operating System Services (Cont.) Operating System Services. Operating System Services (Cont.

Review from last time. CS 537 Lecture 3 OS Structure. OS structure. What you should learn from this lecture

SYSTEM ecos Embedded Configurable Operating System

Chapter 11 I/O Management and Disk Scheduling

INPUT/OUTPUT ORGANIZATION

Intel DPDK Boosts Server Appliance Performance White Paper

Overview of Operating Systems Instructor: Dr. Tongping Liu

Last Class: OS and Computer Architecture. Last Class: OS and Computer Architecture

Exceptions in MIPS. know the exception mechanism in MIPS be able to write a simple exception handler for a MIPS machine

Chapter 3 Operating-System Structures

COS 318: Operating Systems

Last Class: OS and Computer Architecture. Last Class: OS and Computer Architecture

Example of Standard API

The Real-Time Operating System ucos-ii

The Secrets of RS-485 Half-duplex Communication

The I2C Bus. NXP Semiconductors: UM10204 I2C-bus specification and user manual HAW - Arduino 1

Microprocessor & Assembly Language

1 Organization of Operating Systems

COMPUTERS ORGANIZATION 2ND YEAR COMPUTE SCIENCE MANAGEMENT ENGINEERING UNIT 5 INPUT/OUTPUT UNIT JOSÉ GARCÍA RODRÍGUEZ JOSÉ ANTONIO SERRA PÉREZ

Chapter Introduction. Storage and Other I/O Topics. p. 570( 頁 585) Fig I/O devices can be characterized by. I/O bus connections

ELEC 377. Operating Systems. Week 1 Class 3

DEVICE DRIVERS AND TERRUPTS SERVICE MECHANISM Lesson-14: Device types, Physical and Virtual device functions

I/O Management. General Computer Architecture. Goals for I/O. Levels of I/O. Naming. I/O Management. COMP755 Advanced Operating Systems 1

Operating System Structure

Mutual Exclusion using Monitors

The Lagopus SDN Software Switch. 3.1 SDN and OpenFlow. 3. Cloud Computing Technology

CPS104 Computer Organization and Programming Lecture 18: Input-Output. Robert Wagner

COMPUTER ARCHITECTURE. Input/Output

Operating Systems Design 16. Networking: Sockets

Read this before starting!

Lecture 25 Symbian OS

Embedded Systems. 6. Real-Time Operating Systems

Hello, and welcome to this presentation of the STM32 SDMMC controller module. It covers the main features of the controller which is used to connect

Operating System Structures

KVM: Kernel-based Virtualization Driver

Operating Systems Overview

21152 PCI-to-PCI Bridge

Using Multipathing Technology to Achieve a High Availability Solution

Operating System Overview. Otto J. Anshus

Virtualization for Cloud Computing

Intel s Virtualization Extensions (VT-x) So you want to build a hypervisor?

1B11 Operating Systems. Input/Output and Devices

Operating System Structures

Process Description and Control william stallings, maurizio pizzonia - sistemi operativi

Chapter 2 System Structures

Chapter 2 Basic Structure of Computers. Jin-Fu Li Department of Electrical Engineering National Central University Jungli, Taiwan

Network Scanning: A New Feature for Digital Copiers

Virtual Machines. COMP 3361: Operating Systems I Winter

Storport in Windows Server 2003: Improving Manageability and Performance in Hardware RAID and Storage Area Networks

OpenBSD s New Suspend and Resume Framework

Operating Systems and Networks

Solid State Storage in Massive Data Environments Erik Eyberg

How To Understand And Understand An Operating System In C Programming

Microkernels, virtualization, exokernels. Tutorial 1 CSC469

Operating system Dr. Shroouq J.

theguard! ApplicationManager System Windows Data Collector

Red Hat Linux Internals

System Software and TinyAUTOSAR

ARM Thumb Microcontrollers. Application Note. Software ISO 7816 I/O Line Implementation. Features. Introduction

Kernel comparison of OpenSolaris, Windows Vista and. Linux 2.6

UNIT 4 Software Development Flow

Security Overview of the Integrity Virtual Machines Architecture

What is a bus? A Bus is: Advantages of Buses. Disadvantage of Buses. Master versus Slave. The General Organization of a Bus

Embedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C

Transcription:

CSC501 Operating Systems Principles I/O Devices 1

Previous Lectures q Abstraction Q Process Q Memory q Now Q I/O Devices

Basic Computer Architecture CPU memory I/O Devices

Intel SR440BX Motherboard CPU System Bus & MMU/AGP/PCI Controller Memory I/O Bus IDE Disk Controller USB Controller Serial & Parallel Ports Another I/O Bus Keyboard & Mouse

OS Designer s Perspective q The largest, most complex subsystem in OS q Most lines of code with the highest rate of code changes Q Where OS engineers most likely to work Q Difficult to test thoroughly Q Big impact on performance and perception Q Bigger impact on acceptability in market

Principles of I/O Software q Efficiency - Do not allow I/O operations to become system bottleneck, especially for slow devices q Generality - Provide a common API to access I/O devices Q Uniform naming/interface v open, close read, write Q Device independence v isolate OS and application programs from device specific details and peculiarities v isolate the impact of device errors, retry where possible Errors are abundant in I/O 6

I/O Software Stack I/O API & libraries User Level Software Device Independent Software (Rest of the OS) Device Dependent Device Drivers Device Dependent as short as possible Interrupt Handlers Hardware

Communication with I/O Devices q Programmed I/O (a.k.a., polling) q Interrupt-Driven I/O q DMA-based I/O 8

Programmed I/O (Polling) q Used when device and controller are relatively quick to process an I/O operation Q Device driver v Gains access to device v Initiates I/O operation v Loops testing for completion of I/O operation v If there are more I/O operations, repeat Q Used in following kinds of cases v Service interrupt time > Device response time v Device has no interrupt capability Any Example? v Embedded systems where CPU has nothing else to do

Interrupt-Driven I/O q Interrupts occur on I/O events Q Operation completion Q Error or change of status q Interrupt handling Q Step 1: Save the current machine state Q Step 2: Load the machine state for interrupt handling Q Step 3: Invoke the corresponding ISR Q Step 4: Resume the program execution Any Example? Question: Where do we save the current machine states?

DMA-Based I/O q Direct Memory Access Q Device read/write directly from/to memory Q Transfer from memory to device typically initiated from CPU Q Transfer from device to memory can be initiated by the device or the CPU Any Example? 11

DMA-Based I/O 12

Communication with I/O Devices q Comparison: Polling, Interrupt, and DMA Q Polling and Interrupt = word at a time Q DMA = block at a time CPU Memory CPU Memory CPU Memory Interconnect Interconnect Interconnect Disk Disk Disk Polling Interrupt DMA

Question: How should the device driver be designed? 14

Device Driver q Hides the device specifics from the above layers Q Supporting a common API q Translates logical I/O into device I/O Q E.g., logical disk blocks into {head, track, sector} Q Performs data buffering and scheduling of I/O operations q Structure Q Several synchronous entry points: device initialization, queue I/O requests, state control, read/write Q An asynchronous entry point to handle interrupts

Device Driver A Typical Design q OS and driver communication: OS-dependent Q Commands and data between OS and drivers v Meet the interface specs of the device independent layer v Utilize the facilities supplied by the OS buffers, error codes, etc. q Driver and hardware comm.: Device-dependent Q Commands and data between driver and hardware v Actions during interrupt handling 16

Device Driver A Typical Design q Driver operations Q Initialize devices Q Interpret commands from OS Q Schedule multiple outstanding requests Q Manage data transfer Q Accept and process interrupts Q q Typically use open-close-read-write paradigm Q Support open, close, read, write, seek functions Q Use ioctl function as escape mechanism 17

Uniform API (e.g., in Linux) 18

Case Study w/ Xinu q Code divided into two parts Q Upper Half v Defines abstract operations v Executed by application to request I/O Q Lower Half v Device-specific interrupt routine v Executed by arbitrary (current) process v Invoked when operation completes U s e r system call Device specific upper-half routine Device specific lower-half routine Device Device switch table devtab[ ] 19

Case Study w/ Xinu q Device switch table Q One row per device Q One column per operation Q Entry points to a procedure 20

int dvnum; (*dvinit)(); (*dvshutdown)(); (*dvopen)(); (*dvclose)(); (*dvread)(); (*dvwrite)(); (*dvseek)(); Ptrs to device specific high-level routines (*dvgetc)(); (*dvputc)(); (*dvcntl)(); (*dviint)(); (*dvoint)(); dvcsr; Device Switch Table char int dvivec; dvovec; *dvioblk; dvminor; Ptr to device control block device switch table entry ( struct devsw) The structure of the control block varies from device to device. The control block contains information associated with the device. 21

Case Study w/ Xinu q Device switch table Q Device-independent operations generic Q Given operation may not apply to given device v Example: seek on keyboard or network Q All entries in device switch table must be valid Any solution? 22

Case Study w/ Xinu q Device switch table Q Device-independent operations generic Q Given operation may not apply to given device v Example: seek on keyboard ornetwork Q All entries in device switch table must be valid q Special Entries Q ionull v Used for innocuous operation, always returns OK Q ioerr v Used for incorrect operation, always returns SYSERR 23

Example Device Driver tty in Xinu q Used for I /O to console q Separate input and output buffers q Use semaphores to synchronize q Upper-half routines Q ttyinit, ttyopen, ttyclose, ttyread, ttywrite, ttyputc, ttygetc, ttypcntl q Lower-harf routines Q ttyiin (input interrupt handler) Q ttyoin (output interrupt handler) 24

Example Device Driver tty in Xinu q Actions during a character output Q Upper-half v Waits for buffer space v Deposits character v Triggers device Q Lower-half v Extracts character and pass to device v Signals space semaphore 25

Next Lecture q Hard Disk Q Scheduling and RAID 26