What is needed to create thread safe queues?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

What is needed to create thread safe queues?

1,209 次查看
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 回复数

903 次查看
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 项奖励
回复

902 次查看
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 项奖励
回复