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.

Running Tasks without Sync elements

Hi,

I´m having trouble running some tasks that do not contain any sync elements (such as semaphores, events...). For instance:

void Task1()

{

while(1)

a ++;

}



void Task2()

{

while(1)

b++;
}

I´m running Task1 with higher priority than Task2. However Task2 is never getting executed, dispatcher is never giving cycles to it...

Is not possible to run Tasks that do not contain any sync element?

Thanks

  • Nicloas,
    Since Task1 has higher priority it runs first and without a means for it to yield, Task2 will never run. You need to have either a synchronization primitive, a Task_yield (used to switch if Task1 and Task2 had equal priority) or simply a Task_sleep. In your case a simple Task_sleep will cause Task1 to yield to Task2 for the amount of time you specify in the Task_sleep.

    Let me know if this helps.

    Moses
  • Hi Moses,


    Right, thanks , I see. So it sounds to me like the rtos is behavnig in a cooperative way rather than preemptive..
    Is there a document summarizing such functions like Task_yield(), Task_sleep,...?


    Best.
    Nicolás Díez
  • Nicolás,

        There's preemption involved too. Tasks with higher priority once they're available to run  can preempt lower priority tasks.The TI-RTOS kernel has 3 threading modules: Hwi's, Swi's and Tasks. There's more preemption when you go from one type of thread to the other. Task's are at the bottom of the preemption chain and can be preempted by Hwi's and Swi's. Swi's can only be preempted by Hwi's. I recommend you first read the Threading Modules chapter of the TI-RTOS User's Guide and here's the API reference for learning more about the different functions.

    Let me know if this helps

    Moses