Lecture 7 System architecture Input-output

Slides:



Advertisements
Similar presentations
Computer Architecture
Advertisements

Dr. Rabie A. Ramadan Al-Azhar University Lecture 3
1 (Review of Prerequisite Material). Processes are an abstraction of the operation of computers. So, to understand operating systems, one must have a.
Slide 4-1 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 4 Computer Organization.
CSCI 4717/5717 Computer Architecture
CS-334: Computer Architecture
FIU Chapter 7: Input/Output Jerome Crooks Panyawat Chiamprasert
Interrupts What is an interrupt? What does an interrupt do to the “flow of control” Interrupts used to overlap computation & I/O – Examples would be console.
COMP3221: Microprocessors and Embedded Systems Lecture 15: Interrupts I Lecturer: Hui Wu Session 1, 2005.
Architectural Support for Operating Systems. Announcements Most office hours are finalized Assignments up every Wednesday, due next week CS 415 section.
1 Computer System Overview OS-1 Course AA
Basic Input/Output Operations
TECH CH03 System Buses Computer Components Computer Function
1 Interrupts INPUT/OUTPUT ORGANIZATION: Interrupts CS 147 JOKO SUTOMO.
INPUT/OUTPUT ORGANIZATION INTERRUPTS CS147 Summer 2001 Professor: Sin-Min Lee Presented by: Jing Chen.
Input/Output. Input/Output Problems Wide variety of peripherals —Delivering different amounts of data —At different speeds —In different formats All slower.
Chapter 7 Input/Output Luisa Botero Santiago Del Portillo Ivan Vega.
Interrupts. What Are Interrupts? Interrupts alter a program’s flow of control  Behavior is similar to a procedure call »Some significant differences.
Chapter 10: Input / Output Devices Dr Mohamed Menacer Taibah University
Dr. Rabie A. Ramadan Al-Azhar University Lecture 6
MICROPROCESSOR INPUT/OUTPUT
CHAPTER 3 TOP LEVEL VIEW OF COMPUTER FUNCTION AND INTERCONNECTION
Top Level View of Computer Function and Interconnection.
Computer Architecture Lecture10: Input/output devices Piotr Bilski.
Computer Architecture Lecture 2 System Buses. Program Concept Hardwired systems are inflexible General purpose hardware can do different tasks, given.
EEE440 Computer Architecture
Lecture 14 Today’s topics MARIE Architecture Registers Buses
The computer system’s I/O architecture is its interface to the outside world. This architecture provides a systematic means of controlling interaction.
Computer Organization CDA 3103 Dr. Hassan Foroosh Dept. of Computer Science UCF © Copyright Hassan Foroosh 2002.
Digital Computer Concept and Practice Copyright ©2012 by Jaejin Lee Control Unit.
Input/Output Problems Wide variety of peripherals —Delivering different amounts of data —At different speeds —In different formats All slower than CPU.
Input Output Techniques Programmed Interrupt driven Direct Memory Access (DMA)
بسم الله الرحمن الرحيم MEMORY AND I/O.
9/20/6Lecture 3 - Instruction Set - Al1 Exception Handling.
Chapter 3 System Buses.  Hardwired systems are inflexible  General purpose hardware can do different tasks, given correct control signals  Instead.
Chapter 2: Computer-System Structures(Hardware)
CHAPTER 9: Input / Output
CS501 Advanced Computer Architecture
Microprocessor Systems Design I
CHAPTER 9: Input / Output
Control Unit Lecture 6.
Lesson Objectives Aims Key Words Interrupt, Buffer, Priority, Stack
Computer Architecture
CPU Sequencing 6/30/2018.
Interrupts In 8085 and 8086.
Introduction of microprocessor
Computer System Overview
Dr. Michael Nasief Lecture 2
Chapter 3 Top Level View of Computer Function and Interconnection
Chapter 8 Input/Output I/O basics Keyboard input Monitor output
Interrupt Driven I/O References Text: Tanenbaum ch.1.4.3, ch Receiver Interrupt Program Example:
Operating Systems Chapter 5: Input/Output Management
MARIE: An Introduction to a Simple Computer
Interrupts.
Md. Mojahidul Islam Lecturer Dept. of Computer Science & Engineering
Md. Mojahidul Islam Lecturer Dept. of Computer Science & Engineering
Interrupt handling Explain how interrupts are used to obtain processor time and how processing of interrupted jobs may later be resumed, (typical.
Lecture 6 CdM-8 CPU overview
Lecture 13 Harvard architecture Coccone OS demonstrator
COMP3221: Microprocessors and Embedded Systems
William Stallings Computer Organization and Architecture 7th Edition
Chapter 13: I/O Systems.
Lecture 12 Input/Output (programmer view)
Chapter 13: I/O Systems “The two main jobs of a computer are I/O and [CPU] processing. In many cases, the main job is I/O, and the [CPU] processing is.
Presentation transcript:

Lecture 7 System architecture Input-output Computing platforms, semester 2 Novosibirsk State University University of Hertfordshire D. Irtegov, A.Shafarenko 2019

CdM-8 as a chip Unmarked outputs on the top: register monitors IRQ, vector and IAck we will discuss later In and out buses are memory bus

CdM-8 in von Neumann (Manchester) setup

CdM-8 in Harvard setup

I/O as a memory cell Sequential logical device is a set of registers some combinatory logic If we make some registers available to CPU, we can Read [parts of] state of the device It is up to device designers to make this part of the state usable Change state of the device (issue commands and transfer data)

I/O device: [part of] keyboard and a display

Reading data from the keyboard Uppermost (7th) bit of data latch is reset to 0 on key press And to 1 on data read Thus, CPU can poll (repeatedly read) the data until bit 7 is 0 While polling, CPU cannot do anything else Also, polling leads to high CPU load and power consumption If CPU does something else (timed polling), it cannot react to keyboard immediately In multithreaded programming, polling is considered harmful But on low level I/O you sometimes have no other choice

Code sample

Interrupts (alternative to polling) Interrupts are hardware service that allows I/O devices to signal events CPU to handle (process) them Require changes to CPU internal architecture CPU must poll IRQ signal on every fetch cycle If the signal is present, instead of fetching next instruction CPU starts interrupt handling sequence To handle interrupt, CPU saves parts of its state (PC and PS registers) and calls a handler (interrupt service routine, ISR)

Changes to CdM-8 CPU Interrupt Master (IM) , which senses interrupt requests, decides if the interrupt must be granted and fetches the interrupt vector from the device Interruptable Sequencer latching Virtual Interrupt Instruction (VII) instead of a normal Fetch based on the PC. Extension of the Secondary Decoder to accommodate the execution of the VII, Extension of the Instruction Set with the rti instruction (return from interrupt): the last instruction that an ISR must execute. Interrupt Arbiter handles the situation when several devices request interrupts at overlapping periods

Why handle interrupts only on Fetch stage? If we handle interrupts only between ISA instructions, we can save registers needed for ISR programmatically (and not save ones not needed) If we handle interrupts inside of the instructions, we must save all state of the CPU, including registers which are not available programmatically (IR, RR, RX, sequencer state) In industrially used CPU, that would break compatibility between CPUs with same ISA but different RTL architecture (e.q. AMD and Intel)

Peripherals … IM Sequencer Secondary Decoder … … Primary Decoder PS PC vector IM int IRQ … Interrupt Arbiter Interrupt Arbiter vec-adr IAck IRQ v1 IAck IRQ v2 IAck device i/f device i/f hold fetch int enabled DP triggers phase1 Sequencer Secondary Decoder … int … latch phase5 fetch op-code fetch logic Primary Decoder taken CVZN branch logic PS PC=PC+1 read latch shared with DP instr cond PC Memory instr IR DP selectors addr shared with DP int

Interrupts from software point of view Every interrupt-capable device has unique number on range 0 to 7 Every possible value of device numbers selects a byte pair, called interrupt vector By default, interrupt vectors are mapped to upper 16 bytes of memory In Manchester architecture, these are same bytes as used for memory mapped I/O, so you cannot use all 7 interrupts and all 16 register addresses In Harvard architecture, I/O is mapped to data memory, and vectors to program memory

But what happens when interrupt occurs? Device sets IRQ request on CPU input line When CPU finishes every instruction, it polls IRQ request line If interrupts are enabled (we will discuss this later), it retrieves device number Then, instead of instruction at mem[PC], VII (ioi) instruction is executed In some sence, ioi is “normal” instruction: it has an opcode, it can be inserted in a machine code and executed like any other command This is called “software interrupt” But during interrupt, no ioi instruction is present at mem[PC] But CPU behaves like it fetched this instruction

Ioi instruction Phase 1 decrement SP for stack push Phase 2 store PC on stack; decrement SP for stack push Phase 3 store PS on stack Phase 4 fetch new PC value from vector’s first cell (0xf0 + 2R) Phase 5 fetch new PS value from vector’s second cell (0xf1 + 2R) It is similar to jsr, but two registers are saved (PC and PS) You need to use rti instruction to return from ioi routine And call target depends on hardware (device number R) So you can write specific handler routine for every device

What you can do in interrupt handler? Typically, interrupt signals that device has some data for you So you must retrieve the data Some devices require further instructions, what to do next For example, when you read data from the disk, you must tell the disk what sector to read or write next (or not tell anything and disk will be idle) Then you must set some flags so main program will know the data are ready Then you must return to main program (execute an rti instruction) Or you can do something else (we will discuss it in Operating Systems course)

Why interrupts are bad? They are asynchronous They can occur in any moment of program execution It is very easy to write a handler that can break a main program (damage its data) And it is very hard to catch this condition by testing So, there is a mechanism to disable interrupts (a flag in PS register) Interrupt handling is a simplest (and historically first) form of parallel programming, and parallel programming has many pitfalls And most of these pitfalls are hard to avoid There will be courses on concurrency and parallel programming further in our curriculum

Why interrupts are good? You can handle several event sources at same time You do not need to rewrite your program to add another event source You can do something useful when waiting for an event Operating systems use interrupts to implement multithreading and multitasking

Terminal device Has a full ASCII keyboard and ASCII display I/O port is shared: in is kbd, out is screen Kbd sends interrupt when key is pressed

Terminal device driver ISR reads the char from keyboard And inserts it into a ring buffer Main program can read the data from the buffer, when it is not busy with other tasks Output data are put to the screen immediately Code is in the tome.pdf