11/30/2006
My lecture ended at 4:45pm, plus or minus, today. At 5:04pm, the following email message hit my mailbox: Wed, 29 Nov 2006 17:04:29 -0600 Subject: priority you talked a lot today in class about processes getting interrupted by higher priority. but im just curious of what happens in this situation... say im running my garbage process at 0 priority. in the middle of this a priority 6 interrupts me. no big deal, i push my current position and go to the newer higher priority process. now in the middle of the new priority 6 program, a priority 3 program hits us. how is this situation handled? it seems like we would need something like a linked list to make sure this priority 3 process isnt lost. thanks :) <<name withheld to protect the nurturer of lower priority interrupts>> Excellent question! ...and a very simple answer. Let's assume the LC-3 computer was executing a priority 0 program when a priority 6 interrupt occurred. And, so the LC-3 is now executing a priority 6 interrupt service routine. In the middle, someone hits a key on the keyboard. Since bits 15 and 14 in the KBSR are both 1, the output of the AND gate is 1. BUT, since the priority of the Keyboard device is lower than the priority of the executing interrupt service routine, the priority 6 interrupt service routine continues unmolested. BUT, since the key has been hit, bit [15] stays at 1 until the KBDR is accessed. And, presumably the operating system does not change its mind about enabling interrupts. That means bit [14] also stays at 1. That means the output of the AND gate stays at 1. At some point the interrupt service routine for the priority 6 interrupt finishes with an RTI instruction, causing the PSR and PC of the priority 0 program to be popped off the stack and loaded into their respective registers. Before that program can resume, Bingo! The keyboard interrupt priority is higher than the priority of the program that is running (actually, about to start running), so the keyboard interrupt service routine interrupts, and the priority 0 program is again pushed onto the stack. The bottom line. Interrupts are signals that a particular priority level event wants to interrupt the program that is running. That signal remains asserted until it is serviced, and that happens when the priority of the executing program is lower than the priority of interrupt that wants to grab the processor. One final example. Let time travel from left to right. Suppose interrupts arrive at the points in time indicated. Suppose each program requires 8 time steps. Interrupts arrive: 0 6 5 4 1 7 Priority of executing program: 000666666660005555555777777775444444441111111100 OK? Yale Patt