46
K
A
DAK
Application Tasks
3.12 Task Enhancements
AMX offers several task enhancements which, although rarely used, can occasionally
come in handy. These enhancements are briefly summarized below.
Task Control Block Extension
Within a task's Task Control Block, 16 bytes are reserved for the private use of the task.
Their use is completely determined by the application.
A Task Control Block for a particular task can be located using procedure ajtktcb. The
private storage is located at offset AMTCBUSR in the Task Control Block.
If you are coding in C, you must use structure definition amxtcbs from header file
AMX831SD.H to access this storage.
If you are coding in assembly language, you must use structure definition AMXTCBS from
header file AMX831SD.DEF to access this storage.
Stack Fences
When AMX creates a task, it installs a fence at the top and bottom of the task's stack.
The fence is a 32-bit value containing the unusual pattern 0x55555555 ('UUUU').
The 4-character task tag is copied to the stack immediately below the top fence as a
debugging aid to identify each stack's owner.
These fences can be of significant help during the development and testing of your AMX
system. When you are trying to detect a fault in your system, it is often advisable to
examine your task stacks carefully to be sure that none of the fences have been altered.
An altered fence is an indication that you have a task which is overflowing or
underflowing its stack or, worse yet, a bad piece of code which is writing to some task's
stack in error.