Skip navigation.
Home
The QNX Community Portal

View topic - mq_notify

mq_notify

anything that doesn't fit to other groups.

mq_notify

Postby sheran.vaz » Thu Jun 09, 2016 2:40 pm

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?
sheran.vaz
Active Member
 
Posts: 98
Joined: Mon May 11, 2009 9:17 am

Re: mq_notify

Postby nico04 » Thu Jun 09, 2016 3:05 pm

Do you really need mq to communicate inside your process ?
mq is a "heavy" solution. It's usage is more for inter process communication.
nico04
Active Member
 
Posts: 81
Joined: Wed Sep 29, 2010 9:59 am
Location: France

Re: mq_notify

Postby sheran.vaz » Thu Jun 09, 2016 3:12 pm

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.
sheran.vaz
Active Member
 
Posts: 98
Joined: Mon May 11, 2009 9:17 am

Re: mq_notify

Postby Tim » Thu Jun 09, 2016 5:35 pm

You should consider using pthread conditional variables within your process.

http://www.qnx.com/developers/docs/6.3. ... _init.html
http://www.qnx.com/developers/docs/6.3. ... _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.

Tim
Tim
Senior Member
 
Posts: 1391
Joined: Wed Mar 10, 2004 12:28 am

Re: mq_notify

Postby nico04 » Fri Jun 10, 2016 6:20 am

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.
nico04
Active Member
 
Posts: 81
Joined: Wed Sep 29, 2010 9:59 am
Location: France

Re: mq_notify

Postby sheran.vaz » Fri Jun 10, 2016 6:04 pm

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.
sheran.vaz
Active Member
 
Posts: 98
Joined: Mon May 11, 2009 9:17 am


Return to General Programming

Who is online

Users browsing this forum: No registered users and 4 guests