user3712774
user3712774

Reputation: 69

Implementation of semaphore in Queues in freeRtos

Is queues in freeRtos from the beginning also mutual exclusive, by that i mean, shall i create some kind of mutual exclusion for writing or reading from a queue, or is it already implemented by the function xQueueRead and xQueueSend.

Upvotes: 3

Views: 1038

Answers (2)

Étienne
Étienne

Reputation: 4994

FreeRTOS queues are thread-safe, you don't need to implement your own locking. See the FreeRTOS documentation about queues:

Queues are the primary form of intertask communications. They can be used to send messages between tasks, and between interrupts and tasks. In most cases they are used as thread safe FIFO (First In First Out) buffers

Upvotes: 1

Nenad Radulovic
Nenad Radulovic

Reputation: 902

If you look at the source in "queue.c" you will notice that xQueueGenericSend() and xQueueGenericReceive() functions are using tastENTER_CRITICAL()/taskEXIT_CRITICAL() macro pair to ensure atomic operation of the function, which, in a sense, is kind of mutual exclusion you are asking for.

Upvotes: 1

Related Questions