Create and start a task

int RTX_Create_Task ( int far *taskID,
                      const TaskDefBlock far *taskdefblock );



Output Parameter:   Pointer to 16 bit storage for the taskID, allocated by the caller


Input Parameter:   Pointer to a TaskDefBlock type data structure prepared by caller.

Return Value

0, task is running, output location taskID contains the 16 bit taskID
non-zero --> error code.


The caller must fill in portions of the TaskDefBlock structure prior to making this call.

The new task is immediately placed in the system's task ready queue.   Execution begins if the task is higher priority than any other task currently ready (including task which called RTX_Create_Task ). This function differs with RTX_Create_Task_Without_Run in that the new task is released to run within this function call.

You may want to use the helper_alloc_rtos_mem API to allocate the new task's stack space.   You can then optionally use the helper_assign_mem API to reassign this stack space memory allocation to the new task.   This step would be taken after this RTX_Create_Task API has provided you the new task ID.   Assigning the stack memory allocation to the task has the advantage that this stack memory will then be released automatically by the system when this new task is later deleted from the system.

Caution:    For small or medium memory model, the task's stack allocation will need to be made from the program data segment in order that the model's DS == SS flat segment requirement be met.   This means that the RTOS memory allocation cited here will not be a good idea for these memory models.   Although small or medium memory models provide more efficient programs than large memory model, the large memory model is highly recommended for all users interested in getting their program up and running without a lot of adventure.

See Also


This library function invokes a RTOS software interrupt. Refer to this RTOS API function's documentation for more details.

Related Topics

IPC@CHIP® System Tasks
RTX API   Overview

Supported since or modified in @CHIP-RTOS version


This API List
List of C Libraries
@CHIP-RTOS Main Index

End of document