IPC@CHIP® RTOS-LNX – API Documentation
Task creation specification. More...
This structure is used by RTX_NewTask() to create a new task.
The four character task name is not strictly required. But it is helpful for diagnostic purposes. For example, the TASKS command lists the tasks' names with status information for all tasks running in the system.
The RTX_TASK_PROC type for the vectors to the task entry point specify one
long input parameter. This input parameter is optional and the actual task procedure may be declared with void parameters, or any other type of the same size as
long such as a pointer to an object. Then the task entry vector can be cast to RTX_TASK_PROC type when assigned to the tkdProc member.
The task's input parameter is specified in the tkdlParam member. A pointer to an object can be cast to
long and set as this member's value for object oriented tasks.
A pointer to the bottom (lowest address) of the tasks stack space must be set in the tkdStackBase member. Note that unlike the task definition API in the SC1x, SC2x and SC1x3 systems, this pointer does not reference the high end of the stack space. Alternatively, you can specify a NULL pointer. In this case the stack will be automatically allocated by the system.
The system requires a minimum of 32768 bytes stack space for all tasks.
If the tkdStackBase member is non NULL, the user is responsible for allocating this stack space. This can be done either with a static allocation or from the program heap memory.
When deciding how large to make the task's stack, it may be wise during program development to make the stack larger than you think will be necessary. Then after the software is running, use the TASKS console command to check your task's stack space usage. You can then trim the stack down to some more reasonable size.
Some thought should be given to your task priority selection set in the tkdPriority member. For reference, the program's main() thread is launched by the system at priority 50. Priorities can be changed at run time with the RTX_Task_Priority() API.
Refer to the multitasking overview for a further discussion of task priorities.
Commonly, the tkdAttr member can be left at zero and all the remaining members of this data structure can be ignored since that is what the system is going to do with them when
tkdAttr is zero.
The following features are available by setting flags in the tkdAttr bit field.
The tkdSlice member can be set to the number of milliseconds that either a task time-slice period or watchdog time-limit shall be set to. Either the RTX_TA_TIME_SLICED or RTX_TA_TIME_LIMIT flags must be set in the tkdAttr bit field member (but not both) for the
tkdSlice value to be applied. The time value will be limited by the @CHIP-RTOS-LNX to around 65 seconds if any value higher than this is specified, due to range limitations on the CPU's decrementer hardware register which is used to implement this timer.
Tasks are charged for time stolen by interrupt service procedures, but they are not charged for time spent within tasks which preempt them.