![Infineon Technologies XC2200 User Manual Download Page 171](http://html1.mh-extra.com/html/infineon-technologies/xc2200/xc2200_user-manual_2055439171.webp)
XC2200 Derivatives
System Units (Vol. 1 of 2)
Central Processing Unit (CPU)
User’s Manual
4-33
V2.1, 2008-08
CPUSV2_X, V2.2
4.5.2
Context Switching
When a task scheduler of an operating system activates a new task or an interrupt
service routine is called or terminated, the working context (i.e. the registers) of the left
task must be saved and the working context of the new task must be restored. The CPU
context can be changed in two ways:
•
Switching the selected register bank
•
Switching the context of the global register
Switching the Selected Physical Register Bank
By updating bitfield BANK in register PSW the active register bank is switched
immediately. It is possible to switch between the current memory-mapped GPR bank
cached in the global register bank (BANK = 00
B
), local register bank 1 (BANK = 10
B
),
and local register bank 2 (BANK = 11
B
).
In case of an interrupt service, the bank switch can be automatically executed by
updating bitfield BANK from registers BNKSELx in the interrupt controller. By executing
a RETI instruction, bitfield BANK will automatically be restored and the context will
switched to the original register bank.
The switch between the three physical register banks of the register file can also be
executed by writing to bitfield BANK. Because of pipeline dependencies an explicit
change of register PSW must cancel the pipeline.
Figure 4-8
Context Switch by Changing the Physical Register Bank
After a switch to a local register bank, the new bank is immediately available. After
switching to the global register bank, the cached memory-mapped GPRs must be valid
before any further instructions can be executed. If the global register bank is not valid at
this time (in case if the context switch process has been interrupted), the cache
validation process is repeated automatically.
MCA04877
Interrupt of
Task B
recognized
Execution of
RETI
Execution Task A
Execution Task B
ExecutionTask A
Global Bank
Local Bank
Global Bank