Required reading: Chapter 9, 10, 11, and 12 (until sys1.c)
Conceptually interrupts are implemented by adding a wire between device and processor; when the device raises the signal on the wire, it sets the "interrupted" gate on the processor. The processor checks the gate between each instruction, and if the gate is set, it invokes the kernel-entering mechanism described above. (The actual implementation is more complicated: to support critical sections, the processor can disable interrupts temporarily. Furthermore, the processor might have multiple interrups levels, as the PDP-11 does.)
| saved PSW | | saved PC (2) | <- sp
| saved old PSW | | saved PC (2) | <- sp | | | saved new PSW |
| saved old PSW | | saved PC | | saved r0 | <- sp | saved new PSW |
| saved old PSW | | saved PC | | saved r0 | | saved new PSW | | saved r1 | | SP from previous mode | | saved new PSW & !037 | <- sp
| saved old PSW | | saved PC | | saved r0 | | saved new PSW | | saved r1 | | SP from previous mode | | saved new PSW & !037 | | return address pc (787) | // trap came from user space | saved r5 | <- r5 | saved r4 | | saved r3 | | saved r2 | | cret | <- sp
| saved old PSW | | saved PC | | saved r0 | | saved new PSW | | saved r1 | | SP from previous mode | | saved new PSW & !037 | <- sp
| saved old PSW | | saved PC | | saved r0 | | saved new PSW | | saved r1 | <- sp
| saved PSW | | saved PC | <- sp
| saved old PSW | | saved PC | | saved r0 | | saved new PSW | <- sp
| saved old PSW | // previous mode was either kernel or user | saved PC | // address to resume execution of interrupted program | saved r0 | | saved new PSW | // the one from the location vector (br6) | saved r1 | | SP from previous mode | // kernel or user stack pointer | saved new PSW & !037 | // = 0, unused in clock | return address pc (787 or 800) | // depending on previous mode | saved r5 | <- r5 | saved r4 | | saved r3 | | saved r2 | | cret | <- sp