2 Replies Latest reply on Feb 20, 2018 7:27 PM by AxLi_1746341

    do we need mutexes while using queues?

    ritu_2178811

      Hello,

       

      Queues are meant to send data between threads so I guess there is already a synchronization mechanisim inside but since I didn't see it in the documentation. I wanted to ask.

      do queues in wiced sdk have internal synchronization mechanism? or should we use a mutex

      thanks

        • 1. Re: do we need mutexes while using queues?

          I found a queston about ThreadX at here : multithreading - access a threadx-queue concurrently - Stack Overflow

          This maybe a fundemental for embedded programming, but I thing it should written at docs (not shown at 5.0.1 doc).

           

          Another question, how can I find which backend I am using (ThreadX, RTOS, etc) ?

          1 of 2 people found this helpful
          • 2. Re: do we need mutexes while using queues?
            AxLi_1746341

            riforifo wrote:

             

            Hello,

             

            Queues are meant to send data between threads so I guess there is already a synchronization mechanisim inside but since I didn't see it in the documentation. I wanted to ask.

            do queues in wiced sdk have internal synchronization mechanism? or should we use a mutex

            thanks

            Both ThreadX and FreeRTOS provide thread safe APIs to access the queue.

            However, the WICED API level is racy for ThreadX build because it directly

            dereferences the data structure in the RTOS.

            e.g. wiced_rtos_get_queue_occupancy/wiced_rtos_is_queue_empty/wiced_rtos_is_queue_full

             

            Add locking does not help, because the RTOS does not hold the lock adding by WICED API layer while accessing the data structure.

            It's simply buggy.