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: Posting a Semaphore to Higher priority task from current task Problems

Other Parts Discussed in Thread: CC3200

Tool/software: TI-RTOS

Hi ,

I am using cc3200 running tirtos_cc32xx_2_16_01_14 version,

Now here is my problem, When i post a semaphore to a higher priority task from a lower priority Ti-RTOS does not switch to the Higher priority task immediately
Instead it finishes current task and then goes to Higher priority task. Is this the intended behavior ? any work around ?

//low priority task 5
void abc()
{

// do something here 
// ........
//
semaphore_post(handle);
// continue doing something here
// ....
// ..

}

// High priority task 12
void xyz()
{
Semaphore_pend(handle, BIOS_WAIT_FOREVER);
// do important thing here
}


 Regards


Shashank

  • Hi,

    I tried to use Priority Based Semaphore, I enabled it from config script but how do i set the priority value ?

    Regards
    Shashank
  • Hi,

    Can i get some help regarding the above ?

    Regards

    Shashank

  • Shashank,

    This is not intended behavior. The higher priority task should be scheduled immediately after sem_post.
    Did you check if your low priority task is raising its priority for some critical section processing?
    Also though unlikely, did you check for priority inversion if higher priority task is blocked for any other resource low priority task is holding?

    You can configure priority semaphores, you can do so while creating semaphores like below
    semParams.mode = Semaphore_Mode_COUNTING_PRIORITY;
    semParams.mode = Semaphore_Mode_BINARY_PRIORITY;
  • Prasad Jondhale said:


    Did you check if your low priority task is raising its priority for some critical section processing? 



    No, task priorities are set statically and are not being modified on run time

    Prasad Jondhale said:

    Also though unlikely, did you check for priority inversion if higher priority task is blocked for any other resource low priority task is holding?



    Higher priority task is blocked only on this semaphore and not any other resource

    The semaphores have been configured as priority semaphores correctly using config file,

    Imagine if there are 2 semaphores , How can I set a semaphores priority to the absolute max and then set others to the absolute minimum explicitely ??

    Regards

    Shashank

  • Can you attach a small example with the problem? As Prasad stated, this is not expected behavior.

    Todd

  • Hi Shashank,

    If possible, please share a small example demonstrating the problem as suggested by Todd in an earlier post. In addition, can you try the following experiment (Steps refer to code you shared in first post):
    - Put a breakpoint in function abc() after Semaphore_post() call
    - Once breakpoint is hit, open ROV
    - Check Task detailed view (please share screenshot). It should show each Task's priority and confirm whether or not priority inversion is at play.
    - Check Task module view and determine if Task scheduler is enabled

    I am suspecting that some operation within function abc() is disabling the Task scheduler. Therefore, Semaphore_post() does not result in an immediate context switch to a higher priority task. The above experiment should confirm that speculation.

    Best,
    Ashish