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.

RTOS/EVMK2H: Is one active task of two same priority task able to be preempted by the other task?

Part Number: EVMK2H


Tool/software: TI-RTOS

I have some questions about TI-RTOS task scheduling.

1. Is one active task of two same priority task able to be preempted by the other task?

2. If task A which has a same priority with task B runs and mailbox is posted to task B, is the task A preempted by task B although task A operation is not finished?

  • Hi,

    As far as I know, if there are tasks with equal priorities, whichever gets first to the cpu is executed. It is the programmer's responsibility to avoid race conditions using the timer or locks.

    I am looping the design team to elaborate, if needed.

    Best Regards,
    Yordan
  • Hi MinJi,

    Tasks of the same priority never preempt each other. Say Task A and Task B are the same priority. If Task A is running and Task B becomes ready, Task A continues to run. The only way Task B will run is if
    1. Task A hits a blocking state (e.g. call Task_sleep or Semaphore_pend with a timeout and it's not available, etc.)
    2. Task A calls Task_yield. Task_yield give control to the next ready task with the same priority. If there are now ready, Task_yield returns immediately and Task A continues.
    3. Task A terminates
    4. Task A's priority is lowered or Task B's priority is raised.


    Todd

  • And just to be clear, if Task A is preempted by a higher thread (Hwi, Swi or Task), when that thread is done, Task A will resume (and not Task B).

    [Additionally I edited the above post to add another way (#4) to have Task B run]

    Todd