Task Switching With The Stack Extension - Motorola DSP56600 Manual

Application optimization for digital signal processors
Table of Contents

Advertisement

Program Control

Task Switching with the Stack Extension

3-10
3.4
TASK SWITCHING WITH THE STACK
EXTENSION
A multi-tasking operating system using the stack extension should
ensure stack coherence when switching from one task to the other.
Here is a possible task switching scenario:
1. During the execution of the task "T1", a "time-out" interrupt
occurs indicating the need to replace the active task with task
"T2". The PC and SR of T1 task are pushed onto the stack by
the JSR instruction of the interrupt vector area.
2. The JSR gives control to the Operating System that must now
execute the task switching. First, all the registers are saved in
the register area of task T1:
movec
move
move
....
move
move
move
move
move
....
move
move
3. At this point, all the registers were saved as a mirror of the T1
task, but the stack has some data in it that belongs to the T1
task, as well. This data should also be copied to some
memory area reserved for that information by the operating
system.
;Stack saving:
move
;The next 14 pushes ensure that all the current entries in the
;hardware stack will be automatically saved in the
;stack extension memory:
rep
move
;After these moves are executed, all the hardware stack is stored
;in the memory extension stack area, and the pointers EP and SP
;are updated, so they should be saved:
move
move
4. After all task T1 programming model have been saved, the
Operating System chooses the task T2 as the next task to run.
Optimizing DSP56300/DSP56600 Applications
r7,x:OS_temp
#T1_task_reg_area,r7 ;Load pointer.
x0,x:(r7)+
r6,x:(r7)+
x:OS_temp,r0
r0,x:(r7)+
n0,x:(r7)+
n1,x:(r7)+
lc,x:(r7)+
la,x:(r7)+
sc,x:(r7)+
;Save SC
#14
#dummy,ssh
sp,x:(r7)+
;Save SP
ep,x:(r7)+
;Save EP.
;save r7 in order to
;use is later
;Save registers...
;Save registers...
;Pull r7
;Save r7
;Save n0
;Save n1
MOTOROLA

Advertisement

Table of Contents
loading

This manual is also suitable for:

Dsp56300

Table of Contents