1 / 10

Input/Output Interface

Input/Output Interface. Address bus. Data bus. Control bus. address decoder. address decoder. fffffffc Addr DE. I/O Interface. Mem 1. Mem n. Keyboard. How to do I/O. By “Polling” li $t1 0xfffffffc ;Interface address waitkey: lb $t0 0($t1) ;Poll Keybard

Download Presentation

Input/Output Interface

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Input/Output Interface Address bus Data bus Control bus address decoder address decoder fffffffc Addr DE I/O Interface Mem 1 ... Mem n Keyboard

  2. How to do I/O • By “Polling” li $t1 0xfffffffc ;Interface address waitkey: lb $t0 0($t1) ;Poll Keybard nop beq $t0 $r0 waitkey ;no key strike nop • + Very simple and fast • - Can’t do any useful work while waiting • - Only OK in a single process system, might miss data if other process takes over

  3. External Interrupt Let the Interface generate an External Interrupt when data is available • + Access I/O Interface only when needed • + I/O handling is done by OS (Operating System) • I/O addresses can be “privileged” for SAFETY • + Data is never lost (if processor fast enough) • - Slower than “Polling” • We will address that problem later

  4. Input/Output Interface Address bus Data bus Control bus CTRL[INT2]=keyboard strike fffffffc Addr DE I/O Interface Moore about: Buffered I/O “Intelligent Devices” etc. later. Keyboard

  5. An External Interrupt Occurs • The “context” of the User program must be restored User Program Kernel Program . .. bne $t0 $r0 upp mfc0 $k0 $14 jr $k0 rfe add $t0 $t1 $t2 .. .

  6. Multiple Processes User 1 User 2 User 3 Kernel .text .text .text .ktext Instructions .data .data .data .kdata Data

  7. Time Slicing, Context Switch • On Each Timer Interrupt • Store the User program “Context” • Choose next User program (process) • Round robin process scheduling • Restore its “Context” • Pass control to User program

  8. Process Control Block (PCB) • Resume Address (next PC for this process) • Global Data pointer ($gp) • Stack pointer ($sp) • All registers but $k0, $k1, $gp, $sp • $k0, $k1 might be trashed by the Kernel code • $gp, $sp stored in the PCB

  9. Process Control Block PCB for Process p1 next_pc $gp $sp .text resume addr base for global data area for p1 .data top of user p1 stack .p1 stack $pc,$sp,$gp are initiated by the OS at “run” time

  10. Where are the 28 registers? PCB p1 PCB p1 next_pc $gp $sp Let’s put them on the user program’s stack! next_pc $gp $sp And adjust the $sp $t0 $t1 … .. $t0 $t1 … .. .p1 stack .p1 stack

More Related