Download presentation
Presentation is loading. Please wait.
Published byPaul Swales Modified over 9 years ago
1
Datorteknik IOControl bild 1 Input/Output Interface Address bus Data bus Control bus fffffffc Addr DE...Mem 1 Keyboard address decoder Mem n address decoder I/O Interface
2
Datorteknik IOControl bild 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
Datorteknik IOControl bild 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
Datorteknik IOControl bild 4 Input/Output Interface Address bus Data bus Control bus CTRL[INT2]=keyboard strike fffffffc Addr DE Keyboard I/O Interface More about: Buffered I/O “Intelligent Devices” etc. later.
5
Datorteknik IOControl bild 5 An External Interrupt Occurs The “context” of the User program must be restored User ProgramKernel Program mfc0 $k0 $14 jr $k0 rfe... sub $t1 $t3 $t4 add $t0 $t1 $t2...
6
Datorteknik IOControl bild 6 Multiple Processes User 1KernelUser 2User 3 Instructions Data.text.data.text.data.text.data.ktext.kdata
7
Datorteknik IOControl bild 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
Datorteknik IOControl bild 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
Datorteknik IOControl bild 9 Process Control Block.text.data next_pc $gp $sp resume addr.p1 stack top of user p1 stack base for global data area for p1 $pc,$sp,$gp are initiated by the OS at “run” time PCB for Process p1
10
Datorteknik IOControl bild 10 Where are the 28 registers?.p1 stack $t0 $t1 ….. Let’s put them on the user program’s stack!.p1 stack $t0 $t1 ….. And adjust the $sp PCB p1 next_pc $gp $sp next_pc $gp $sp
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.