Input and Output CS 215 Lecture #20.

Slides:



Advertisements
Similar presentations
Computer-System Structures Er.Harsimran Singh
Advertisements

Computer Architecture
I/O Organization popo.
Categories of I/O Devices
INPUT-OUTPUT ORGANIZATION
CS-334: Computer Architecture
FIU Chapter 7: Input/Output Jerome Crooks Panyawat Chiamprasert
OS2-1 Chapter 2 Computer System Structures. OS2-2 Outlines Computer System Operation I/O Structure Storage Structure Storage Hierarchy Hardware Protection.
1 Lecture 2: Review of Computer Organization Operating System Spring 2007.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 2: Computer-System Structures Computer System Operation I/O Structure Storage.
Midterm Tuesday October 23 Covers Chapters 3 through 6 - Buses, Clocks, Timing, Edge Triggering, Level Triggering - Cache Memory Systems - Internal Memory.
Computer System Structures memory memory controller disk controller disk controller printer controller printer controller tape-drive controller tape-drive.
Input and Output How things get into and out of the CPU.
INPUT/OUTPUT ORGANIZATION INTERRUPTS CS147 Summer 2001 Professor: Sin-Min Lee Presented by: Jing Chen.
Group 7 Jhonathan Briceño Reginal Etienne Christian Kruger Felix Martinez Dane Minott Immer S Rivera Ander Sahonero.
Copyright ©: Nahrstedt, Angrave, Abdelzaher
INPUT-OUTPUT ORGANIZATION
What are Exception and Interrupts? MIPS terminology Exception: any unexpected change in the internal control flow – Invoking an operating system service.
INPUT/OUTPUT ARCHITECTURE By Truc Truong. Input Devices Keyboard Keyboard Mouse Mouse Scanner Scanner CD-Rom CD-Rom Game Controller Game Controller.
1 CSC 2405: Computer Systems II Spring 2012 Dr. Tom Way.
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.
General System Architecture and I/O.  I/O devices and the CPU can execute concurrently.  Each device controller is in charge of a particular device.
Chapter 10: Input / Output Devices Dr Mohamed Menacer Taibah University
1 Computer System Overview Chapter 1. 2 n An Operating System makes the computing power available to users by controlling the hardware n Let us review.
Input and Output Computer Organization and Assembly Language: Module 9.
MICROPROCESSOR INPUT/OUTPUT
CHAPTER 2: COMPUTER-SYSTEM STRUCTURES Computer system operation Computer system operation I/O structure I/O structure Storage structure Storage structure.
Silberschatz, Galvin, and Gagne  Applied Operating System Concepts Module 2: Computer-System Structures Computer System Operation I/O Structure.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Principles of I/0 hardware.
Chapter 2: Computer-System Structures
1 CSE Department MAITSandeep Tayal Computer-System Structures Computer System Operation I/O Structure Storage Structure Storage Hierarchy Hardware Protection.
2: Computer-System Structures
CHAPTER 3 TOP LEVEL VIEW OF COMPUTER FUNCTION AND INTERCONNECTION
Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.
1 Chapter 2: Computer-System Structures  Computer System Operation  I/O Structure  Storage Structure  Storage Hierarchy  Hardware Protection  General.
Computer Architecture Lecture 2 System Buses. Program Concept Hardwired systems are inflexible General purpose hardware can do different tasks, given.
Accessing I/O Devices Processor Memory BUS I/O Device 1 I/O Device 2.
Interrupt driven I/O. MIPS RISC Exception Mechanism The processor operates in The processor operates in user mode user mode kernel mode kernel mode Access.
The computer system’s I/O architecture is its interface to the outside world. This architecture provides a systematic means of controlling interaction.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
1 CS.217 Operating System By Ajarn..Sutapart Sappajak,METC,MSIT Chapter 2 Computer-System Structures Slide 1 Chapter 2 Computer-System Structures.
MIPS I/O and Interrupt.
Silberschatz, Galvin and Gagne  Applied Operating System Concepts Chapter 2: Computer-System Structures Computer System Architecture and Operation.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
Lecture 1: Review of Computer Organization
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.
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
Interrupt driven I/O Computer Organization and Assembly Language: Module 12.
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.
1 Device Controller I/O units typically consist of A mechanical component: the device itself An electronic component: the device controller or adapter.
Interrupts and Exception Handling. Execution We are quite aware of the Fetch, Execute process of the control unit of the CPU –Fetch and instruction as.
Chapter 2: Computer-System Structures
Computer Architecture
Computer-System Architecture
Module 2: Computer-System Structures
Operating Systems Chapter 5: Input/Output Management
Module 2: Computer-System Structures
Chapter 2: Computer-System Structures
Chapter 2: Computer-System Structures
Module 2: Computer-System Structures
Module 2: Computer-System Structures
Interrupts and Exception Handling
Presentation transcript:

Input and Output CS 215 Lecture #20

Motivation I/O devices make computers useful to humans. Input devices may be arbitrarily slow and must have a way to tell the computer that they are ready to supply data. Output devices must have a way of refusing more data until they are ready to receive more.

General Categories of I/O User interface devices. Input devices detect changes and output devices changes the physical world. Input devices: mouse, keyboard Output devices: terminal display, printer Mass storage devices. These devices hold large quantities of data. For example, disks and tape drives. Gateways and networks. Computers communicate with each other and these communication exhibit delays relative to computer speed. Networks can be treated as if they were conventional I/O devices.

The Keyboard The keyboard detects when keys are pressed and sends a designated sequence of characters to the computer. A table is used to map the keys to characters. Some keys like SHIFT, CTRL, ALT, and META either change the mapping of the keyboard or modify the effect of other keys. The bits are usually sent serially at a rate given in bits per second (bit rate).

The keyboard must have a way of indicating to the computer that it has a character to send. This is done using extra bits called start bit and stop bit. The start bit signals the beginning of a transmission and the stop bit signals its end. The computer then knows that data is going to follow after receiving the start bit. The following sequence of bits are saved to an input register. Both start and stop bits are stripped off at the receiving end. In MAL, we can access the input via $v0 or $2.

The Video Display Each time a printable character is sent to the display it reacts by displaying the character in the position where the cursor was, and moving the cursor one position to the right. A terminal consists of a display unit and a keyboard. Thus it is both an input and an output device. When cr is received, the cursor moves to beginning of the current line and does not scroll. When nl is received, scrolling is initiated but the cursor does not move. Combining both moves the cursor to the beginning of the next line.

Hard Disk The disk must first be informed where the data is to be read or written. The disk’s read/write arm seeks to the proper cylinder and rotates to the correct sector. When the read/write arm is in proper position it then informs the computer that it is ready to receive or transmit. At this point it can either transmit data or write data.

Hardware: I/O instructions The hardware implements special instructions to read from/write to I/O devices. Perhaps lwio (load word I/O) and swio The devices have a separate address space from memory lwio $s0, 16 and lw $s0, 16 access different data lwio $s0, 16 reads the next word from device 16 lw $s0, 16 reads the word stored in memory location 16. MIPS does NOT use special I/O instructions

Memory-Mapped I/O The hardware can be designed in such a way that some memory addresses are not really memory at all but a collection of communication channels to I/O devices. In memory-mapped I/O, load and store from/to the communication channels provide a means of performing I/O, i.e., load and store instructions with an I/O address are treated as I/O operations. lw $2, KeyboardData sw $5, DisplayData communication channels

MIPS RISC architecture uses memory-mapped I/O MIPS RISC architecture uses memory-mapped I/O. Note that the hardware must support this. Memory-mapped I/O is one method by which the processor and I/O devices communicate via a common bus. In this case, one common bus for memory and I/O are used with common control lines. The I/O devices unlike memory may unavailable. If a device is not ready to accept or transmit data then it is said to be not ready or busy. The processor communicates with I/O using two addresses: one for data exchange and the other to obtain status of the I/O device.

Memory mapped addresses in SPIM keyboard_control = 0xffff0000 display_control = 0xffff0008 keyboard_data = 0xffff0004 display_data = 0xffff000c Data 7 6 5 4 3 2 1 0 Control 1 0 Interrupt enable (1 = enabled) Device busy/ready (1 = ready)

Memory mapped addresses in SPIM Define the memory mapped constants like this: .data 0xffff0000 keyboard_control: .space 4 keyboard_data: .space 4 display_control: .space 4 display_data: .space 4

Programmed I/O In programmed I/O, the CPU stays in a loop until the I/O unit indicates that is ready for data transfer or if the CPU has issued a command to the I/O module it must wait until the operation is complete. wait: lw $14,keyboardstatus beqz $14,wait lw $2,keyboardData wait: lw $14,displaystatus sw $2,displayData 1 = ready 0 = busy most significant bit

Direct Memory Access (DMA) A controller is a device that has registers and can execute routines on its own given necessary parameters. A DMA controller is given by the CPU the starting address into which a block of data will be transferred and the amount of data to be transferred. It also has a control register and a status register. The DMA controller requests memory cycle from the memory controller. During a DMA transfer the CPU executes from cache while control of the memory bus is given to the DMA controller

A code a DMA controller might execute .data count: .word 1024 begin_file: .space 1024 .text initialize: lw $15,count #number of characters la $16,begin_file #address where to store waitloop: lw $14,diskstatus beqz $14, waitloop lb $2,diskdata #read a character sb $2,($16) #store into the array sub $15,1 #decrement counter add $16,1 #adjust array pointer bgtz $15,waitloop

Exception Mechanism Instead of spin-waiting or doing a regular check whether an I/O device is ready, the I/O device can just inform the CPU that it is ready to receive or transmit data. The I/O device sends an interrupt signal to the system. In this mechanism, control is transferred to a different program which saves the current state of the interrupted program. The requests are then serviced and control is given back to the interrupted program. This mechanism is called an exception.

An interrupt is one class of exception. An interrupt can occur at any time. Hardware and software are needed to support interrupt handling. The hardware must choose the appropriate time in which to interrupt the executing program and transfers control to an exception handler. The exception handler must save the current state of the interrupted program. The exception handler also determines which event has caused the exception and decides what should be done based on it.

Since an exception handler can be invoked anytime, an exception handler can not have parameters nor it can return values. It must also save register values being used by the interrupted program and restore them before returning control to the interrupted program.

Software: Interrupt Driven I/O Exceptions come in two varieties Interrupts are generated by hardware I/O device Clock Power down Traps are generated by code execution Division by zero Illegal memory address System call

How interrupt driven I/O works User code/data Kernel data Display .text . la $a0, A li $v0, 4 syscall .data A: .asciiz “cat” Output buffer

How interrupt driven I/O works User code/data Kernel data Display .text . la $a0, A li $v0, 4 syscall .data A: .asciiz “cat” Output buffer c a t

How interrupt driven I/O works User code/data Kernel data Display .text . la $a0, A li $v0, 4 syscall .data A: .asciiz “cat” Output buffer c c a t

How interrupt driven I/O works User code/data Kernel data Display .text . la $a0, A li $v0, 4 syscall .data A: .asciiz “cat” Output buffer ca c a t

How interrupt driven I/O works User code/data Kernel data Display .text . la $a0, A li $v0, 4 syscall .data A: .asciiz “cat” Output buffer cat c a t

Role of the Operating System The operating system is a program that allocates and controls the use of all system resources: the processor, memory, and I/O devices. Since there are many processes that can run concurrently, the operating system uses interrupt to allocate the processor to different processes periodically -- allowing processes to share processing time with each other. The exception handler plus other codes used to decide what process should be executed next is called the kernel.

In saving the current values of registers in MIPS RISC architecture, addresses needed to be formed to store them into memory. The formation of addresses requires the use of registers -- thus $26 and $27 are reserved for the operating system so that when an interrupt is to be serviced there is no need to save the contents of these two registers. The other type of exception is a trap. A trap occurs when an event happens as a direct result of executing a program, e.g. caused by an overflow or an attempt to access a memory outside of the legal range.