Keil Logo

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


func is the name of the task function.
task_id is 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 */


  • 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

  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.