Keil™, An ARM® Company

RTX166 Tiny User's Guide

Defining Tasks

Real-Time or multitasking applications are composed of one or more tasks that perform specific operations. RTX166 Tiny supports a maximum of 32 tasks.

Tasks are simply C functions that have a void return type and a void argument list and are declared using the _task_ function attribute. For example:

void func (void) _task_ task_id

where

funcis the name of the task function.
task_idis a task ID number from 0 to 31.

The following example defines the function job0 as task number 0. This task increments a counter and repeats.

void job0 (void) _task_ 0 {
  while (1) {
    counter0++; /* increment counter */
  }
}

Note

  • All tasks should be implemented as endless loops. A task should never return.
  • Tasks cannot return a function value. They must have a void return type.
  • Parameters may not be passed to a task. Tasks must have a void argument list.
  • Each task must be assigned a unique, non-recurring task ID.
  • To minimize the memory requirements of RTX166 Tiny, number your tasks sequentially beginning with 0.

Related Knowledgebase Articles