What is needed to create thread safe queues?

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

What is needed to create thread safe queues?

1,287件の閲覧回数
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?

タグ(3)
0 件の賞賛
返信
2 返答(返信)

981件の閲覧回数
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 件の賞賛
返信

980件の閲覧回数
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 件の賞賛
返信