249
Chapter 5 Operating System Issues
or Am29050 processor. A system designer can use this feature to reduced context
switch times.
5.3
ASYNCHRONOUS CONTEXT SWITCH
An asynchronous context switch occurs when the current task unexpectedly
gives up the processor to enable another task to execute. This may occur when a timer
interrupt results in the supervisor deciding the current task is no longer the task of
highest priority. Unlike at the point at which a synchronous context switch occurs,
when an interrupt occurs the state of the processor is not restricted to a simple state.
Because an interrupt may occur in a leaf procedure, it is not possible to
determine if the current
lr1
value contains a valid pointer to the top of the procedure
activation record. Further, the interrupt may have occurred during a procedure
prologue, where the register stack pointer (
gr1
) has been lowered but the
lr1
value
has not yet been updated. This means when an asynchronous–saved task is switched
back in, it is impossible to restore only the activation record of the interrupted
procedure. The register stack containing valid data, that is [
gr1
]––[
rfb
], must be
restored. Assuming this amounts to half of the register file, an additional 2.6 micro
seconds would be required to restore the task with a single–cycle Am29000
processor memory system at 25MHz.
A task voluntarily giving up the processor via a system call from within a
procedure of typical activation record size can be restored faster then a task giving up
the processor involuntarily via an asynchronous interrupt.
When a User mode program is interrupted it could mean the current process is to
be sent a signal, such as a segmentation violation. It could also mean that the
Supervisor wishes to gain control of the processor to support servicing the
interrupting device. If the current process is being signaled, the label
user_signal
should be jumped to by Supervisor mode interrupt handler (see the example code
below). This is explained in the later section titled
User Mode Signals (
section 5.5). If
Supervisor support code is required for peripheral device servicing, then the action to
be taken is very much dependent on the interrupting device needs.
.equ
SIGALRM,14
;alarm signal
time_out:
;timer interrupt handler
jmp
const
interrupt_common
it0,SIGALRM
;signal number
interrupt_common:
;Depending on required processing,
;jump to user_signal for current process signaling.
;Or, jump to user_interrupt to save the current process context.
Some interrupts can be serviced in Freeze mode, without the need to save the
current process context. Use of these so–called
lightweight
interrupt handlers can