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

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

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

Computer Systems Structure Input/Output

Chapter 11 I/O Management and Disk Scheduling

Chapter 02: Computer Organization. Lesson 04: Functional units and components in a computer organization Part 3 Bus Structures

Devices and Device Controllers

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

Communicating with devices

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

I/O Device and Drivers

Introduction. What is an Operating System?

1. Computer System Structure and Components

CSC 2405: Computer Systems II

Computer Organization & Architecture Lecture #19

Chapter 6. Inside the System Unit. What You Will Learn... Computers Are Your Future. What You Will Learn... Describing Hardware Performance

INPUT/OUTPUT ORGANIZATION

Fastboot Techniques for x86 Architectures. Marcus Bortel Field Application Engineer QNX Software Systems

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

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

The Bus (PCI and PCI-Express)

Operating System Overview. Otto J. Anshus

Obj: Sec 1.0, to describe the relationship between hardware and software HW: Read p.2 9. Do Now: Name 3 parts of the computer.

Operating System Structures

What is involved in input/output? How does the operating system manage I/O?

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

Chapter 1 Lesson 3 Hardware Elements in the Embedded Systems Chapter-1L03: "Embedded Systems - ", Raj Kamal, Publs.: McGraw-Hill Education

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

SOFTWARE TECHNOLOGIES

Computer Performance. Topic 3. Contents. Prerequisite knowledge Before studying this topic you should be able to:

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

Operating Systems 4 th Class

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

Low Profile Ultra ATA-133 RAID PCI Host

Page 1 of 5. IS 335: Information Technology in Business Lecture Outline Operating Systems

Computer Architecture Prof. Mainak Chaudhuri Department of Computer Science and Engineering Indian Institute of Technology, Kanpur

Machine Architecture and Number Systems. Major Computer Components. Schematic Diagram of a Computer. The CPU. The Bus. Main Memory.

Microkernels, virtualization, exokernels. Tutorial 1 CSC469

Multimedia Systems Hardware & Software THETOPPERSWAY.COM

Chapter 5 Busses, Ports and Connecting Peripherals

Overview of Operating Systems Instructor: Dr. Tongping Liu

Operating Systems. Lecture 03. February 11, 2013

CS 61C: Great Ideas in Computer Architecture Virtual Memory Cont.

UMBC. ISA is the oldest of all these and today s computers still have a ISA bus interface. in form of an ISA slot (connection) on the main board.

Operating System Structure

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

Programming Interface. for. Bus Master IDE Controller. Revision 1.0

Lizy Kurian John Electrical and Computer Engineering Department, The University of Texas as Austin

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

OpenSPARC T1 Processor

Input/output (I/O) I/O devices. Performance aspects. CS/COE1541: Intro. to Computer Architecture. Input/output subsystem.

A Deduplication File System & Course Review

Computer Architecture

PC Notebook Diagnostic Card

11: I/O Device Management

Plug and Play for Windows 2000

Chapter 1 Computer System Overview

Chapter 3 Operating-System Structures

85MIV2 / 85MIV2-L -- Components Locations

CS161: Operating Systems

Chapter 5 Cubix XP4 Blade Server

Network Attached Storage. Jinfeng Yang Oct/19/2015

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

Read this before starting!

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

IDE/ATA Interface. Objectives. IDE Interface. IDE Interface

TEST CHAPTERS 1 & 2 OPERATING SYSTEMS

Digitale Signalverarbeitung mit FPGA (DSF) Soft Core Prozessor NIOS II Stand Mai Jens Onno Krah

CHAPTER 2: HARDWARE BASICS: INSIDE THE BOX

Operating system Dr. Shroouq J.

Programming PCI-Devices under Linux

Device Drivers: Their Function in an Operating System

A+ Guide to Managing and Maintaining Your PC, 7e. Chapter 1 Introducing Hardware

Products. CM-i586 Highlights. Página Web 1 de 5. file://c:\documents and Settings\Daniel\Os meus documentos\humanoid\material_o...

COMPUTER HARDWARE. Input- Output and Communication Memory Systems

Operating System Fundamentals Robert Power & Robert Ford

Knut Omang Ifi/Oracle 19 Oct, 2015

Chapter 8 Objectives. Chapter 8 Operating Systems and Utility Programs. Operating Systems. Operating Systems. Operating Systems.

Data Cables. Schmitt TTL LABORATORY ELECTRONICS II

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. System Components Operating System Services System Calls System Programs System Structure Virtual Machines

Introduction Disks RAID Tertiary storage. Mass Storage. CMSC 412, University of Maryland. Guest lecturer: David Hovemeyer.

Logical Operations. Control Unit. Contents. Arithmetic Operations. Objectives. The Central Processing Unit: Arithmetic / Logic Unit.

New Mexico Broadband Program. Basic Computer Skills. Module 1 Types of Personal Computers Computer Hardware and Software

Chapter 2: OS Overview

Product Support Bulletin

OPERATING SYSTEMS STRUCTURES

ADVANCED PROCESSOR ARCHITECTURES AND MEMORY ORGANISATION Lesson-17: Memory organisation, and types of memory

Big Picture. IC220 Set #11: Storage and I/O I/O. Outline. Important but neglected

Learning Outcomes. Simple CPU Operation and Buses. Composition of a CPU. A simple CPU design

CS 377: Operating Systems. Outline. A review of what you ve learned, and how it applies to a real operating system. Lecture 25 - Linux Case Study

Phoenix SecureCore TM Setup Utility

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

Operating Systems Overview

Hardware Based Virtualization Technologies. Elsie Wahlig Platform Software Architect

Chapter 6, The Operating System Machine Level

Price/performance Modern Memory Hierarchy

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

Operating Systems: Basic Concepts and History

Transcription:

I/O Input/Output One of the functions of the OS, controlling the I/O devices Wide range in type and speed The OS is concerned with how the interface between the hardware and the user is made The goal in designing the OS is to provide a uniform interface (e.g. if I replace my HD I d like to see the same sort of filesystem) OS 2003 1 OS 2003 2 Device Data rate [byte/s] Types of devices Keyboard Mouse 56K modem 10 bytes/s 100 bytes/s 7Kb/s Block devices: random addressable, blocks of fixed size Example: disks Character: stream of date, they don t have a seek operation Example: terminal, printer, mouse, etc. Others: Timers and clocks OS 2003 3 Telephone channel ISDN line Scanner Ethernet (10Mbit) USB Digital camcorder IDE disk 40x CD Ethernet (100Mbit) ISA bus Firewire (IEEE1394) XGA monitor SCSI ultra 2 disk Gigabit Ethernet PCI bus 8Kb/s 16Kb/s 400Kb/s 1.25Mb/s 1.5Mb/s 4Mb/s 5Mb/s 5Mb/s 12.5Mb/s 16.7Mb/s 50Mb/s 60Mb/s 80Mb/s 125Mb/s 528Mb/s OS 2003 4 Computer hardware Interface Processors Memory I/O devices Buses CPU Mem Video Buses Floppy Controllers Controller and device Controller: a piece of electronics Device: the mechanics Interface E.g. for a disk, a bit-stream with a preamble, a certain amount of bits (4096) of a sector, and finally an error-correcting code (ECC). OS 2003 5 OS 2003 6 1

Example: floppy drive Specific chip (NEC PD765) 16 different commands Load between 1 and 9 bytes into a device register Read/Write require 13 parameters packed into 9 bytes Reply from the device consists of 7 bytes (23 parameters) Control of the motor (on/off) OS 2003 7 Memory mapped I/O Two solutions: Memory mapped registers or buffers (e.g. the display buffer) Special I/O instructions IN/OUT instructions A mix of the two 0xFFFFFFFF 0x00000000 Memory 0xFFFF 0x0000 I/O space OS 2003 8 Pentium example I/O ports (using IN and OUT): 0 to 64K I/O buffers: from 640K to 1M 0xFFFFFFFF 1M 640K 0x00000000 I/O buffers 0xFFFF 0x0000 I/O space OS 2003 9 How do they fare in practice? Address is put in the bus. Another line tells whether the address is I/O or memory. For memory mapped I/O: C/C++ instructions can write into I/O registers No special protection is needed (beside the usual one needed to protect memory pages) Every instruction can reference memory (e.g. can do a TEST without loading into a register first) For special I/O instructions: Don t need to disable caching selectively as for memory mapped Multiple buses, need a way to send the memory address on all the buses where it might be required (e.g. memory bus, PCI, etc.) Pentium solution: the PCI bridge chip(s) does the filtering of addresses (e.g. the 640 to 1M area) OS 2003 10 DMA DMA s steps BUS CPU 1. CPU programs the DMA controller DMA controller Disk controller Address Buffer Count 4. Ack Control 5. Interrupt when done 2. DMA requests transfer to memory Disk 3. Data transferred Main memory 1. CPU programs the DMA controller by setting its registers (where and what to transfer) 2. DMA controller issues the request to read from the disk. The memory address where to write to is passed along with the READ request 3. Data is read and then transferred to memory directly by the HD controller 4. ACK is sent to the DMA controller to tell the transfer is completed 5. The DMA controller interrupts the CPU to tell the data is in main memory now. OS 2003 11 OS 2003 12 2

DMA sophistication Interrupts One word at a time or block mode: Word at a time: cycle stealing Block or burst mode Many lines and multiple requests Similar in principle but can accept many requests simultaneously DMA controllers use physical addresses Not virtual addresses CPU 3. 2. Interrupt controller queue 1. Interrupt lines OS 2003 13 OS 2003 14 Interrupt (old slide) A piece of hardware called interrupt controller 1. CPU issues the I/O request via the device driver 2. On termination the device signals the CPU s interrupt controller (if the interrupt controller is not busy servicing another higher priority interrupt) 3. If the interrupt can be handled then the controller asserts a pin on the CPU. 4. The interrupt controller puts the address of the device into the bus CPU 3 4 Interrupt controller 1 2 Disk drive Controller On occurrence of interrupt Save information about the state of the CPU: PC at least Where to save the information: Stack (page faults?), user or kernel mode? Internal registers, beware of a second interrupt, interrupting the copy, delay the ACK More troubles: Pipeline, at the moment of interrupt, some instructions are only partly executed, the PC might not even point to the last fully executed instruction On superscalar CPU things are even worse (instructions executed out of order) OS 2003 15 OS 2003 16 Definition Precise interrupt, when: The PC is saved in a known place All instructions before the one pointed to by the PC have fully executed No instruction beyond the one pointed to by the PC has been executed The execution state of the instruction pointed to by the PC is known Pentium Starting from the PPRO the Pentium has a superscalar architecture The price paid to have precise interrupts (and being compatible with 486 s) is in chip complexity A part of the chip allows instructions to complete after the interrupt has been issued and empties the remainder of the pipeline OS 2003 17 OS 2003 18 3

General goals I/O Software OS 2003 19 Device independence: E.g. use the floppy as you use the HD or CD Uniform naming: Related to device independence Use a common naming system (e.g. within the filesytem hierarchy) Error handling: Errors should be handled as low-level as possible, e.g. an error on disk might be serviced by re-reading the sector already from the controller Make calls appear synchronous: Blocking vs. non-blocking Buffering: Keep data being transferred at a constant rate OS 2003 20 Ways of doing I/O Programmed I/O The CPU does all the work Interrupt-driven We ve already said a lot about interrupts DMA-based We ve already said a lot about DMA Programmed I/O copy_from_user (buffer, p, count); for (i = 0; i < count; i++) { while (*printer_status_reg!= READY); *printer_data_register = p[i]; } return_to_user(); OS 2003 21 OS 2003 22 Interrupt-driven I/O DMA-based I/O copy_from_user(buffer, p, count); enable_interrupts(); while (*printer_status_reg!=ready); *printer_data_register = p[0]; scheduler(); if (count == 0) { unblock_user(); } else { *printer_data_register = p[i]; count = count 1; i = i + 1; } copy_from_user(buffer, p, count); set_up_dma_controller(); scheduler(); ack_interrupt(); unblock_user(); return_from_interrupt(); ack_interrupt(); return_from_interrupt(); OS 2003 23 OS 2003 24 4

Software layers User level I/O software Device-independent OS software Device drivers Interrupt handlers Hardware Interrupt handlers How to hide interrupts: Caller does a Wait on a semaphore Interrupt handler does a Post on the semaphore The user process knows nothing of the interrupt (it just blocks for some time) OS 2003 25 OS 2003 26 In reality the OS Save any register that wasn t saved by the HW Set up the context for the handler to run. E.g. setup TLB, MMU, page table, etc. Set up a stack for the handler ACK the interrupt controller Copy registers from where they were saved (stack) E.g. the interrupted process not necessarily will continue next Run the interrupt handler Maybe communicating again with the HW controller Choose which process to run next (scheduler) Setup the MMU, TLB, etc. for the process to run next Load the new process registers Start running the new process A nightmare! OS 2003 27 Device drivers Device-specific code talking to the device controller E.g. a SCSI driver could control a set of SCSI disks or CD In order to access the HW, the device driver needs to be part of the kernel Loadable at run time To be compiled into the kernel Since the OS writer doesn t know in advance which device will be attached to the machine Well-defined model of how the DD interacts with the kernel OS 2003 28 Functions Character/block interface Accept abstract read/write requests and translates into actual commands to the HW Check status of the device when R/W are issued E.g. start/stop motor if disk is not ready Parameters/addresses conversion Blocking vs. non-blocking Reentrant code An interrupt might cause another request on the same device driver already running By the way Device drivers are a source of troubles In fact, a buggy DD can interfere with the kernel leading to unpredictable results Likely a system crash! A nice architecture would see the DD not being part of the kernel Microkernel architecture we mentioned some time ago OS 2003 29 OS 2003 30 5

Device independent I/O Uniform interfacing Buffering Error reporting Allocating and releasing dedicated devices Providing device-independent block size Uniform interfacing Required, otherwise how could the OS call the DD? Not all devices are identical, but There is a finite number of classes though Protection E.g. it is better not to leave anyone the control of the printer OS 2003 31 OS 2003 32 Buffering Continuous flow of data E.g. from a modem Requires something like double-buffering Time is required to move data around (kernel, user space) Buffering can affect performance Delay Other issues Error reporting The OS should try to do its best before complaining Allocation of dedicated devices Possible deadlocks E.g. a CD burner Uniform block size Show all disks as having the same block size OS 2003 33 OS 2003 34 User space I/O Spooling: Daemon + spooling directory It solves the problem of not leaving control of devices completely to the user Example: printer Spooling area Device driver User process Daemon Kernel OS 2003 35 6