
250
Evaluating and Programming the 29K RISC Family
offer significant performance gains. Other interrupts will require the interrupted
process context to be saved. This is described in the following section,
Interrupting
User Mode
(section 5.4).
It is possible an interrupt has arrived that requires a signal to be sent to a process
which is not the currently executing process. In this case, the operating system must
first save the current process context and then restore the context of the signaled
process. Once the in–coming process is prepared to run, using the code in the
Restore
Context
section (section 5.10), the restored context will have to be then placed on the
signal stack as described in the
User Mode Signals
(section 5.5). Thus, execution
would begin in the User mode trampoline code of the in–coming process. To follow
this in detail, later sections of the chapter shall have to be studied.
5.4
INTERRUPTING USER MODE
This section describes how the operating system can prepare the processor to
execute a C level interrupt handler, where the handler is to run in Supervisor mode
and the interrupt occurred during User mode code execution.
Because the User mode task is being asynchronously interrupted, the complete
processor state must be saved. The context information should be stored in the PCB
rather than a temporary stack, as a context switch to a new user task may occur after
the interrupt has been processed. Storing the state in the PCB saves having to copy
the state from the temporary stack to the PCB after the context switch decision has
been made. When saving task context, a performance optimization is obtained by
only saving the registers which are currently in use. However, such optimizations
typically only apply to synchronous–task context saving.
When User mode is interrupted, the special purpose support registers may
contain valid data. This means an additional nine special register data values must be
copied to external data memory, compared to the synchronous context switch.
Below is a code example of interrupt context saving. Notice the
rab
stack
support register is adjusted to a window distance below
rfb
within the interrupt
disabled portion of the code. This is to conform to the same PCB format used by those
who wish to perform the register stack fix–up with User mode code, rather than in the
Supervisor code shown. Register
rab
is merely a convenience value for determining
rfb
–WindowSize (WindowSize normally 512) in detecting a
SPILL
condition.
However, it is also used to determine
FILL
or
SPILL
interruption. Should the User
mode stack fix–up code be interrupted during it’s operation, it is important that it does
not become confused with the original
SPILL
or
FILL
interrupt. Realigning the
rab
register whilst interrupts are off prevents this confusion.
.equ
WS,512
;Window Size
user_interrupt
:
push
;saving User mode context
;stack signal id
pcb,it0