Copy PS onto the stack;
Copy r1 onto the stack;
Copy the stack pointer for the previous address space onto the stack. (This is only significant if the previous mode was user mode).
This represents a special case of the “mfpi” instruction. See the “PDP11 Processor Handbook”, page 6-20;
Copy the copy of PS onto the stack and mask out all but the lower five bits. The resulting value designates the cause of the interrupt (or trap). The original value of the PS had to be captured quickly;
Test if the previous mode is kernel or user.
If the previous mode is kernel mode the branch is taken (0784). PS is changed to show the previous mode as user mode (0798);
The specialised interrupt handling routine pointed to by r0 is entered. (In this case it is the routine “clock”, which is discussed in detail in the next chapter.)
When the “clock” routine (or some other interrupt handler) returns, the top two words of the stack are deleted. These are the masked copy of the PS and the copy of the stack pointer;
r1 is restored from the stack;
Delete the copy of PS from the stack;
Restore the value of r0 from the stack;
Finally the “rtt” instruction returns to the “kernel” mode routine that was interrupted;
If the previous mode was user mode it is not certain that the interrupted routine will be resumed immediately;
After the specialised interrupt routine (in this case “clock”) returns, a check (“runrun 0”) is made to see if any process of higher priority than the current process is ready to run. If the decision is to allow the current process to continue, then it is important that it be not interrupted as it restores its registers prior to the “return from interrupt” instruction. Hence before the test, the processor priority is raised to seven (line 0787), thus ensuring that no more interrupts occur until user mode is resumed. (Another interrupt may occur immediately thereafter, however.)
If “runrun 0”, then another, higher priority, process is waiting. The processor priority is reset to 0, allowing any pending interrupt to be taken. A call is then made to “swtch” (2178), to allow the higher priority process to proceed. When the process returns from “swtch”, the program loops back to repeat the test.
The above discussion obviously extends to all interrupts. The only part which relates specifically to the clock interrupt is the call on the specialised routine “clock”.