Within a single process, Can mq_notify be used to send notification for Q1(queue) to T1’s(thread) C1(channel) and also Q2(queue) to T2’s(thread) C2(channel)? (or) is it like a single process can use mq_notify, only for 1 queue at an instant?

Do you really need mq to communicate inside your process ?
mq is a “heavy” solution. It’s usage is more for inter process communication.

Good question. The reason Qs were choosen is because the thread which feeds this queue is of higher priority than the reader threads. We do not want the high priority thread to get blocked because the critical section is locked by lower priority thread.

You should consider using pthread conditional variables within your process. … _init.html … _init.html

The idea is you create a regular pthread mutex and then put that into a conditional variable.

The mutex protects access to your queue (a simple C++ list/vector or roll your own etc). The condition variable lets the reader threads sleep until the queue is non-empty at which time they can wake up, get the mutex, pull an entry from the queue to process and then release the mutex.


On my side, I have written a FIFO (a queue) in C.
I use a mutex to protect access to a circular buffer and a semaphore to represent the amount of valid entries in the FIFO.
Appending an entry in the FIFO adds the entry in the buffer tail and posts to the semaphore.
Getting an entry from the FIFO waits for the semaphore and removes head entry from the buffer.

Thanks for the inputs.

The problem was with the sequencing, i hadn’t created the connection to receive the first notification.

Agree that Queues are heavier than accessing local circular buffer, which is inside the same process address space.