1 Lecture 14 Buses and I/O Data Transfer Peng Liu

Slides:



Advertisements
Similar presentations
IT253: Computer Organization
Advertisements

Lecture 21Comp. Arch. Fall 2006 Chapter 8: I/O Systems Adapted from Mary Jane Irwin at Penn State University for Computer Organization and Design, Patterson.
1  1998 Morgan Kaufmann Publishers Interfacing Processors and Peripherals.
Datorteknik BusInterfacing bild 1 Bus Interfacing Processor-Memory Bus –High speed memory bus Backplane Bus –Processor-Interface bus –This is what we usually.
1/1/ / faculty of Electrical Engineering eindhoven university of technology Architectures of Digital Information Systems Part 1: Interrupts and DMA dr.ir.
FIU Chapter 7: Input/Output Jerome Crooks Panyawat Chiamprasert
Lecture Objectives: 1)Explain the limitations of flash memory. 2)Define wear leveling. 3)Define the term IO Transaction 4)Define the terms synchronous.
Avishai Wool lecture Introduction to Systems Programming Lecture 8 Input-Output.
EE30332 Ch8 DP – 1 Ch 8 Interfacing Processors and Peripherals Buses °Fundamental tool for designing and building computer systems divide the problem into.
S. Barua – CPSC 440 CHAPTER 8 INTERFACING PROCESSORS AND PERIPHERALS Topics to be covered  How to.
OS2-1 Chapter 2 Computer System Structures. OS2-2 Outlines Computer System Operation I/O Structure Storage Structure Storage Hierarchy Hardware Protection.
1 Interfacing Processors and Peripherals I/O Design affected by many factors (expandability, resilience) Performance: — access latency — throughput — connection.
TECH CH03 System Buses Computer Components Computer Function
2. Methods for I/O Operations
Lecture 12 Today’s topics –CPU basics Registers ALU Control Unit –The bus –Clocks –Input/output subsystem 1.
CS-334: Computer Architecture
3/11/2002CSE Input/Output Input/Output Control Datapath Memory Processor Input Output Memory Input Output Network Control Datapath Processor.
CPU BASICS, THE BUS, CLOCKS, I/O SUBSYSTEM Philip Chan.
1 (Based on text: David A. Patterson & John L. Hennessy, Computer Organization and Design: The Hardware/Software Interface, 3 rd Ed., Morgan Kaufmann,
MICROPROCESSOR INPUT/OUTPUT
THE COMPUTER SYSTEM. Lecture Objectives Computer functions – Instruction fetch & execute – Interrupt Handling – I/O functions Interconnections Computer.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Principles of I/0 hardware.
CHAPTER 3 TOP LEVEL VIEW OF COMPUTER FUNCTION AND INTERCONNECTION
I/O Example: Disk Drives To access data: — seek: position head over the proper track (8 to 20 ms. avg.) — rotational latency: wait for desired sector (.5.
Top Level View of Computer Function and Interconnection.
I/O management is a major component of operating system design and operation Important aspect of computer operation I/O devices vary greatly Various methods.
Lecture 35: Chapter 6 Today’s topic –I/O Overview 1.
I/O Computer Organization II 1 Interconnecting Components Need interconnections between – CPU, memory, I/O controllers Bus: shared communication channel.
August 1, 2001Systems Architecture II1 Systems Architecture II (CS ) Lecture 9: I/O Devices and Communication Buses * Jeremy R. Johnson Wednesday,
COMPUTER ORGANIZATIONS CSNB123. COMPUTER ORGANIZATIONS CSNB123 Expected Course Outcome #Course OutcomeCoverage 1Explain the concepts that underlie modern.
MBG 1 CIS501, Fall 99 Lecture 18: Input/Output (I/O): Buses and Peripherals Michael B. Greenwald Computer Architecture CIS 501 Fall 1999.
EEE440 Computer Architecture
Accessing I/O Devices Processor Memory BUS I/O Device 1 I/O Device 2.
ECEG-3202 Computer Architecture and Organization Chapter 3 Top Level View of Computer Function and Interconnection.
L/O/G/O Input Output Chapter 4 CS.216 Computer Architecture and Organization.
CS2100 Computer Organisation Input/Output – Own reading only (AY2015/6) Semester 1 Adapted from David Patternson’s lecture slides:
Chapter 13 – I/O Systems (Pgs ). Devices  Two conflicting properties A. Growing uniformity in interfaces (both h/w and s/w): e.g., USB, TWAIN.
1 Lecture 1: Computer System Structures We go over the aspects of computer architecture relevant to OS design  overview  input and output (I/O) organization.
Chapter 6 Storage and Other I/O Topics. Chapter 6 — Storage and Other I/O Topics — 2 Introduction I/O devices can be characterized by Behaviour: input,
Input/Output Problems Wide variety of peripherals —Delivering different amounts of data —At different speeds —In different formats All slower than CPU.
IT3002 Computer Architecture
Processor Memory Processor-memory bus I/O Device Bus Adapter I/O Device I/O Device Bus Adapter I/O Device I/O Device Expansion bus I/O Bus.
بسم الله الرحمن الرحيم MEMORY AND I/O.
Mohamed Younis CMCS 411, Computer Architecture 1 CMCS Computer Architecture Lecture 26 Bus Interconnect May 7,
Chapter 3 System Buses.  Hardwired systems are inflexible  General purpose hardware can do different tasks, given correct control signals  Instead.
1 Device Controller I/O units typically consist of A mechanical component: the device itself An electronic component: the device controller or adapter.
1 Lecture 13 Architectural Support for OS I/O Peng Liu
Computer Organization & Design 计算机组成与设计 Weidong Wang ( 王维东 ) College of Information Science & Electronic Engineering 信息与通信工程研究所 Zhejiang.
1 load [2], [9] Transfer contents of memory location 9 to memory location 2. Illegal instruction.
CSCE 385: Computer Architecture Spring 2014 Dr. Mike Turi I/O.
Lecture 2. A Computer System for Labs
Bus Interfacing Processor-Memory Bus Backplane Bus I/O Bus
Architectures of Digital Information Systems Part 1: Interrupts and DMA dr.ir. A.C. Verschueren Eindhoven University of Technology Section of Digital.
Chapter 3 Top Level View of Computer Function and Interconnection
Lecture 14 Architectural Support for OS I/O
Overview of Computer Architecture and Organization
Lecture 14 Buses and I/O Data Transfer
Peng Liu Lecture 14 I/O Peng Liu
Lecture 13 Architectural Support for OS I/O
CSC3050 – Computer Architecture
Chapter 13: I/O Systems.
William Stallings Computer Organization and Architecture
Presentation transcript:

1 Lecture 14 Buses and I/O Data Transfer Peng Liu

2 Input/Output Last time in Lecture 13

3 Throughput vs. Response time Throughput –Aggregate measure of amount of data moved per unit time, averaged over a window Measure in bytes/sec or transfers/sec –Sometimes referred to as bandwidth Examples: Memory bandwidth, disk bandwidth Response time –Response time to do a single I/O operation Measured in seconds or cycles –Sometimes referred to as latency Example: Write a block of bytes to disk Example: Send a data packet over the network Review

4 Magnetic Hard Disks Characteristics –Long term, nonvolatile storage –Large, inexpensive, but slow (mechanical device) Usage –Virtual memory (swap area) –File system Review

5 Dependability

6 I/O System Design Example: Transaction Processing Examples: Airline reservation, bank ATM, inventory system, e-business –Many small changes to shared data space Each transaction: 2-10 disk I/Os, ~2M=5M CPU instruction per disk I/O –Demands placed on system by many different users Important Considerations –Both throughput and response times are important High throughput needed to keep cost low (transactions/sec) Low response time is also very important for the users –Terrible locality –Requires graceful handling of failures Redundant storage & multiphase operations

7 I/O Performance Factors Overall performance is dependent upon a many factors –CPU How fast can the processor operate on the data? –Memory system bandwidth and latency Multilevel caches Main memory –System interconnection I/O and memory buses I/O controllers –I/O devices (disks) –Software efficiency I/O device handler instruction path length, OS overhead, etc.

8 I/O System Design Satisfying latency requirement –For time-critical operations –If system is unloaded Add up latency of components Maximizing throughput at steady state (loaded system) –Find “weakest link” (lowest-bandwidth component) –Configure to operate at its maximum bandwidth –Balance remaining components in the system

9 Buses A bus is a shared communication link that connects multiple devices Single set of wires connects multiple “subsystems” as opposed to a point to point link which only two components together Wires connect in parallel, so 32 bits bus has 32 wires of data

10 Advantages/Disadvantages Advantages –Broadcast capability of shared communication link –Versatility New device can be added easily Peripherals can be moved between computer systems that use the same bus standard –Low Cost A single set of wires is shared multiple ways Disadvantages –Communication bottleneck Bandwidth of bus can limit the maximum I/O throughput –Limited maximum bus speed Length of the bus Number of devices on the bus Need to support a range of devices with varying latencies and transfer rates

11 Bus Organization Bus Components –Control Lines Signal begin and end of transactions Indicate the type of information on the data line –Data Lines Carry information between source and destination Can include data, addresses, or complex commands Processor-memory bus or front-side bus or system bus –Short, high-speed bus –Connects memory and processor directly –Designed to match the memory system and achieve the maximum memory-to-processor bandwidth (cache transfers) –Designed specifically for a given processor/memory system (proprietary) I/O Bus (or peripheral bus) –Usually long and slow –Connect devices to the processor-memory bus –Must match a wide range of I/O device performance characteristics –Industry standard

12 Synchronous versus Asynchronous Synchronous Bus –Includes a clock in control lines –Fixed protocol for communication relative to the clock –Advantages Involves very little logic and can therefore run very fast –Disadvantages Every decision on the bus must run at the same clock rate To avoid clock skew, bus cannot be long if it is fast –Processor-memory bus Asynchronous Bus –No clock control line –Can easily accommodate a wide range of devices –No clock skew problems, so bus can be quite long –Requires handshaking protocol

13 Increasing Bus Bandwidth Several factors account for bus bandwidth –Wider bus width Increasing data bus width => more data per bus cycle Cost: More bus lines –Separate address and data lines Address and data can be transmitted in one bus cycle if separate address and data lines are available Costs: More bus lines

14 Increasing Bus Bandwidth Several factors account for bus bandwidth –Block transfers Transfer multiple words in back-to-back bus cycles Only one address needs to be sent at the start Bus is not released until the last word is transferred Costs: Increased complexity and increased response time for pending requests

15 Increasing Bus Bandwidth –Spilt transaction “pipelining the bus” Free the bus during time between request and data transfer Costs: Increased complexity and higher potential latency Spilt transaction bus with separate address and data wires

16 Accessing the Bus How is the bus reserved by a device that wishes to use it? Master-slave arrangement –Only the bus master can control access to the bus –The bus master initiates and controls all bus requests –A slave responds to read and write requests A simple system –Processor is the only bus master –All bus requests must be controlled by the processor –Major drawback is the processor must be involved in every transfer

17 Multiple Masters With multiple masters, arbitration must be used so that only one device is granted access to the bus at a given time Arbitration –The bus master wanting to use the bus asserts a bus request –The bus master cannot use the bus until the request is granted –The bus master must signal the arbiter when finished using the bus Bus arbitration goals –Bus priority – highest priority device should be serviced first –Fairness – Lowest priority devices should not starve

18 Centralized Parallel Arbitration Advantages –Centralized control where all devices submit request –Any fair priority scheme can be implemented (FCFS, round- robin) Disadvantages –Potential bottleneck at central arbiter

19 Operating System Tasks The OS is a resource manager and acts ad the interface between I/O hardware and programs that request I/O Several important characteristics of the I/O system: –I/O system is shared by multiple programs –I/O systems often use interrupts to notify CPU Interrupts = externally generated “exceptions” Typically “Input available” or “Output complete” messages OS handles interrupts by transferring control to kernel mode –Low-level control of an I/O device is complex Managing a set of concurrent events Requirements for correct device control are very detailed I/O device drivers are the most common area for bugs in an OS!

20 OS Communication The operating system should prevent user program from communicating with I/O device directly –Must protect I/O resources to keep sharing fair –Protection of shared I/O resources cannot be provided if user programs could perform I/O directly Three types of communication are required –OS must be able to give commands to I/O devices –I/O device must be able to notify OS when I/O device has completed and operation or has encountered an error –Data must be transferred between memory and an I/O device

21 I/O Commands: A method for addressing a device Memory-mapped I/O: –Portions of the address space are assigned to each I/O device –I/O addresses correspond to device registers –User programs prevented from issuing I/O operations directly since I/O address space is protected by the address translation mechanism

22 I/O Commands I/O devices are managed by I/O controller hardware –Transfers data to/from device –Synchronizes operation with software Command registers –Cause device to do something Status registers –Indicate what the device is doing and occurrence of errors Data registers –Write: transfer data to a device –Read: transfer data from a device

23 Communicating with the CPU Method #1: Polling –I/O device places information in a status register –The OS periodically checks the status register –Whether polling is used dependent upon whether the device can initiate I/O independently For instance, a mouse works well since it has a fixed I/O rate and initiates its own data (whenever it is moved) For others, such as disk access, I/O only occurs under the control of the OS, so we poll only when the OS knows it is active –Advantages Simple to implement Processor is in control and does the work –Disadvantage Polling overhead and data transfer consume CPU time

24 Polling and Programmed I/O

25 I/O Notification Method #2: I/O Interrupt –When an I/O device needs attention, it interrupts the processor –Interrupt must tell OS about the event and which device Using “cause” register(s): Kernel “asks” what interrupted Using vectored interrupts: A different exception handler for each –I/O interrupts are asynchronous events, and happen anytime Processor waits until current instruction is completed –Interrupts may have different priorities –Advantages: Execution is only halted during actual transfer –Disadvantage: Software overhead of interrupt processing

26 I/O Interrupts

Polling vs. Interrupts Polling –Periodically check I/O status register »If device ready, do operation; If error, take action –Common is small or low- performance real-time embedded systems »Predictable timing, low hardware cost –Good if the event arrival rate is predicable or very high –In other systems, wastes CPU time Interrupts –When a device is ready or error occurs, controller interrupts CPU –Interrupt handling »Use cause register to identify the device and device drive –Priority interrupts »Devices needing more urgent attention get higher priority »Can interrupt handler for a lower priority interrupt –Does not waste CPU time but introduces high content switch overhead 27

28 Data Transfer The third component to I/O communication is the transfer of data from the I/O device to memory (or vice versa) Simple approach: “Programmed” I/O –Software on the processor moves all data between memory addresses and I/O addresses –Simple and flexible, but wastes CPU time –Also, lots of excess data movement in modern systems Eg.: Memory->Network->CPU->Network->graphics When want: Memory->Network->graphics So need a solution to allow data transfer to happen without the processor’s involvement

29 Delegating I/O: DMA Direct Memory Access (DMA) –Transfer blocks of data to or from memory without CPU intervention –Communication coordinated by the DMA controller DMA controllers are integrated in memory or I/O controller chips –DMA controller acts as a bus master, in bus-based systems DMA steps –Processor sets up DMA by supplying Identify of the device and the operation (read/write) The memory address for source/destination The number of bytes to transfer –DMA controller starts the operation by arbitrating for the bus and then starting the transfer when the data is ready –Notify the processor when the DMA transfer is complete or on error Usually using an interrupt

Reading a DISK Sector(1) 30

Reading a DISK Sector(2) 31

Reading a DISK Sector(3) 32

33 DMA Problems: Virtual vs. Physical Addresses If DMA uses physical addresses –Memory access across physical page boundaries may not correspond to contiguous virtual pages (or even the same application) Solution1: <1 page per DMA transfer Solution1+: chain a series of 1-page requests provided by the OS –Single interrupt at the end of the last DMA request in the chain Solution2: DMA engine uses virtual addresses –Multi-page DMA requests are now easy –A TLB is necessary for the DMA engine For DMA with physical addresses: pages must be pinned in DRAM –OS should not page to disks pages involved with pending I/O

34 DMA Problems: Cache Coherence A copy of the data involved in a DMA transfer may reside in processor cache –If memory is updated: must update or invalidate “old” cache copy –If memory is read: must read latest value, which may be in the cache Only a problem with write-back caches This is called the “cache coherence” problem –Same problem in multiprocessor systems

35 DMA & Coherence Solution 1: OS flushes the cache before I/O reads or forces write backs before I/O writes –Flush/write-back may involve selective addresses or whole cache –Can be done in software or with hardware (ISA) support Solution 2: Route memory accesses for I/O through the cache –Search the cache for copies and invalidate or write-back as needed –This hardware solution may impact performance negatively While searching cache for I/O requests, it is not available to processor –Multi-level, inclusive caches make this easier Processor searches L1 cache mostly (until it misses) I/O requests search L2 cache mostly (until it finds a copy of interest)

36 I/O Summary I/O performance has to take into account many variables –Response time and throughput –CPU, memory, bus, I/O device I/O devices also span a wide spectrum –Disks, graphics, and networks Buses –Bandwidth, arbitration, and transactions OS and I/O –Communication: Polling and Interrupts –Handling I/O outside CPU: DMA