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/CC1310: TI-RTOS Semaphore

Part Number: CC1310

Tool/software: TI-RTOS

Hi,

Is there a way to know how many Tasks are suspended waiting for a semaphore?

In another RTOS I am doing this:

u8 suspended_threads = 0;
tx_semaphore_info_get(&g_spi_mutex, NULL, NULL, NULL, (ULONG *)&suspended_threads, NULL);

In addition, where can I find the API documentation to TI-RTOS objects such semaphores?

I found this document http://www.ti.com/lit/ug/spruex3t/spruex3t.pdf

But I could not found all information I need in that document.

  • Hello, 

    You can use ROV or  RTOS Analyzer under the Tools menu in CCS 

    Also there is TI RTOS workshop for in depth training. 

    For tasks and semaphores refer to this section of the training

    Regards,

    Prashanth

  • Hi Prashanth,

    I think I did not explain it clear enough.
    My program needs to know if there are any tasks pending on the semaphore in order to my algorithm works. So, see it throught ROV doesn't solve my problem.
    A more complete example:
    u8 suspended_threads = 0;
    tx_semaphore_info_get(&g_spi_mutex, NULL, NULL, NULL, (ULONG *)&suspended_threads, NULL);
    if(suspended_threads)
    {
    // Do something
    }
    else
    {
    // Do another thing
    }

  • Hello Mad River,

    It sounds like you have more than one task pending on a single semaphore and you want to know the number of tasks that are currently pending on this one semaphore. It does not sound to me like a good idea to have more than one task pending on a single semaphore. You should ideally have one semaphore per task. What happens when a semaphore pending on two tasks at same priority level is posted? Which task will be serviced in that case?

    Is there a reason why you are not able to use multiple semaphores for multiple tasks?

    Regards,

    Prashanth

  • Hi,

    Is there a reason why you are not able to use multiple semaphores for multiple tasks?

    I have more than one task which needs to communicate trough the SPI, so I am using this semaphore to grant access to the SPI bus.

    Adding to this, I have a hardware signal which is used to sync a process with another microcontroller in the board.

    First, I use the semaphore to grant access to one of my tasks. Then, when this task have finished, it verifies if other tasks inside the system also need to use the SPI. If no more tasks need to use the SPI, this task can notify the external microcontroler using a I/O pin.

    What happens when a semaphore pending on two tasks at same priority level is posted?

    I don't have two tasks with the same priority.

  • Hello, 

    Instead, can you try creating a flag that is set active when SPI access is busy and check this flag in your tasks? 

    Regards,

    Prashanth

  • I was only verifying if the semaphore object provide that info in his API.
    Since it doesn't do that, I can create a flag and control it manually.

    Thank you.