What is needed to create thread safe queues?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

What is needed to create thread safe queues?

689 Views
daviduhen
Contributor I

Are MQX queues thread safe?  If so, what is the mechanism used?  If not, can anyone share their code for thread safe queues or linked lists?

Tags (3)
0 Kudos
2 Replies

383 Views
Monica
Senior Contributor III

Hello David,

just checking up how is this matter going, did this workaround work?

Please let us know :smileywink:

Best regards,

Monica

0 Kudos

382 Views
c0170
Senior Contributor III

Hello David Uhen,

MQX queues are thread safe, here's a code snippet from queue code file inside source/kernel folder.

boolean _queue_enqueue

(

    QUEUE_STRUCT_PTR         q_ptr,

    QUEUE_ELEMENT_STRUCT_PTR e_ptr

)

{ /* Body */

   _int_disable();

    if ((q_ptr->MAX != 0) && (q_ptr->SIZE >= q_ptr->MAX))

    {

        _int_enable();

        return (FALSE);

    } /* Endif */

    _QUEUE_ENQUEUE(q_ptr, e_ptr);

   _int_enable();

    return (TRUE);

} /* Endbody */

When a queue is being handled, interrupts are disabled. I don't have any example available, perhaps others will share.

Check reference manual, there are only few functions defined, therefore it should be trivial to use.

Regards,

c0170

0 Kudos