A task has an associated Task structure that is defined as follows

    typedef struct CTL_TASK_s CTL_TASK_t;

    struct CTL_TASK_s

    {

      unsigned *stack_pointer;

      unsigned char priority;

      unsigned char state;

      CTL_TASK_t *next;

      CTL_TIME_t timeout;

      CTL_EVENT_SET_t *wait_event_set;

      CTL_EVENT_SET_t wait_events;

      int errno;

      char *name;

    };

stack_pointer points to the saved registers of a waiting task.

The priority is the priority you have assigned to the task - 0 is the lowest priority and 255 is the highest.

The state for a waiting task is defined to be one of the following

- CTL_STATE_RUNNABLE- the task can run.
- CTL_STATE_FINISHED- the task can never run - it has returned from it's starting function.
- CTL_STATE_TIMER_WAIT- the task is waiting for a timeout to expire.
- CTL_STATE_EVENT_WAIT- the task is waiting on an event set.
- CTL_STATE_TIMER_WAIT | CTL_STATE_EVENT_WAIT- the task is waiting for a timeout or an event set.

The next is a pointer to the next task in the wait list or 0. The priority of the next task will be less than or equal to this task.

The timeoutis the timeout value which is defined when state is in CTL_STATE_TIMER_WAIT.

The wait_event_set is a pointer to the event set the task is waiting on and the wait_events are the events it is waiting for.

The errno is the task specific errno value.

The name is a pointer to a null terminated string that is used to name the task for debugging purposes

The fields of a task structure can be read by the application but should not be written.