Keil Logo

Multiple Instances

The RTX kernel enables you to run multiple copies of the same task at the same time. These are called multiple instances of the same task. You can simply create and run the same task several times. This is often required when you design a protocol based stack (like ISDN D channel stack).

The following example shows you how the function task2 can run in multiple instances.

#include <rtl.h>

OS_TID tsk_1, tsk2_1, tsk2_2, tsk2_3;
int cnt;

__task void task2 (void) {
  for (;;) {
    os_dly_wait (2);

__task void task1 (void) {
  /* This task will create 3 instances of task2 */
  tsk2_1 = os_tsk_create (task2, 0);
  tsk2_2 = os_tsk_create (task2, 0);
  tsk2_3 = os_tsk_create (task2, 0);
  /* The job is done, delete 'task1' */
  os_tsk_delete_self ();

void main (void) {
  for (;;);


  • Each instance of the same task must have a unique task ID.
  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.