Chapter 4. Exceptions
4-13
Process Switching
¥
In each exception handlerWhen enough state information has been saved that a
machine check or system reset exception can reconstruct the previous state, set
MSR[RI].
¥
In each exception handlerClear MSR[RI], set SRR0 and SRR1 appropriately, and
then execute
rT
.
¥
Note that the RI bit being set indicates that, with respect to the processor, enough
processor state data remains valid for the processor to continue, but it does not
guarantee that the interrupted process can resume.
4.3.4 Returning from an Exception Handler
The Return from Interrupt (
rT
) instruction performs context synchronization by allowing
previously-issued instructions to complete before returning to the interrupted process. In
general, execution of the
rT
instruction ensures the following:
¥
All previous instructions have completed to a point where they can no longer cause
an exception. If a previous instruction causes a direct-store interface error exception,
the results must be determined before this instruction is executed.
Previous instructions complete execution in the context (privilege, protection, and
address translation) under which they were issued.
The
rT
instruction copies SRR1 bits back into the MSR.
Instructions fetched after this instruction execute in the context established by this
instruction.
Program execution resumes at the instruction indicated by SRR0.
¥
¥
¥
¥
For a complete description of context synchronization, refer to Chapter 6, òExceptions,ó of
The
Programming Environments Manual.
4.4 Process Switching
The following instructions are useful for restoring proper context during process switching:
¥
The
sync
instruction orders the effects of instruction execution. All instructions
previously initiated appear to have completed before the
sync
instruction completes,
and no subsequent instructions appear to be initiated until the
sync
instruction
completes. For an example showing use of
sync
, see Chapter 2, òPowerPC Register
Set,ó of
The
Programming Environments Manual.
The
isync
instruction waits for all previous instructions to complete and then
discards any fetched instructions, causing subsequent instructions to be fetched (or
refetched) from memory and to execute in the context (privilege, translation, and
protection) established by the previous instructions.
The
stwcx.
instruction clears any outstanding reservations, ensuring that an
lwarx
instruction in an old process is not paired with an
stwcx.
instruction in a new one.
¥
¥