This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

work of 2 Tasks in one appliacation

 Hi All!

I tried to run example application which include two different priority tasks. One task has prioroty level 5, second task has priority level 4.

piece of my .cfg file

/* 
 * Create and install logger for the whole system
 */
var loggerBufParams = new LoggerBuf.Params();
loggerBufParams.numEntries = 16;
var logger0 = LoggerBuf.create(loggerBufParams);
Defaults.common$.logger = logger0;
Main.common$.diags_INFO = Diags.ALWAYS_ON;

var task0Params = new Task.Params();
task0Params.priority = 5;
task0Params.instance.name = "task0";
Program.global.task0 = Task.create("&Task1", task0Params);

var task1Params = new Task.Params();
task0Params.priority = 4;
task0Params.instance.name = "task1";
Program.global.task0 = Task.create("&Task2", task1Params);

System.SupportProxy = SysMin;

my main.c :

/*
 *  ======== taskFxn ========
 */
Void Task1(UArg a0, UArg a1)
{
    while(1)
    {
      printf("task1\n\r");
    }
}

Void Task2(UArg a0, UArg a1)
{
    while(1)
    {
      printf("task2\n\r");
    }
    
}

/*
 *  ======== main ========
 */
Int main()

{ 


    System_printf("enter main()\n");

    hardware_init();



     BIOS_start();    /* does not return */

    return(0);
}

So, in with my configuration code of Task2 never hapens, works only routine of Task1.

If I change priority of Task2 from 4 to 6, Task2 routine works well, but Task1 routine never runs.

Why?

  • I think there are a couple of reasons that the Task2 function is not running:

    1) The wrong task parameters are being specified in the configuration code:

    var task1Params = new Task.Params();
    task0Params.priority = 4;
    task0Params.instance.name = "task1";
    Program.global.task0 = Task.create("&Task2", task1Params);

    I think you meant to write “task1Params” fields, but are writing “task0Params” fields instead.  When the second task is created, “task1Params.priority” field was not written, so the default priority of “1” is used.

    2) The Task1() and Task2() functions in main.c will both spin forever in while(1) loops.  Since the task functions don’t call a blocking API, or yield in any way, whichever task is at the highest priority will continue to run, and the lower priority task will never get a chance to run.  Even if both tasks are at the same priority, since neither task will block or yield, the first task allowed to run will continue to run forever, and the second task will never get to run.

    Scott