LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Posix Message queue, mq_receive process conflict (https://www.linuxquestions.org/questions/programming-9/posix-message-queue-mq_receive-process-conflict-768689/)

mbalkan 11-12-2009 12:15 PM

Posix Message queue, mq_receive process conflict
 
Hello all,

I have a problem with my message queue system...

I used to use system V type mq system but then I figured out that posix mq system was existed and was indeed much more efficient..

So my question is this, while I was using System V type message queue I was receiving messages like that;

Code:

MessageBuffer* m_message = malloc(sizeof(MessageBuffer));
int RECEIVER = 2;

(...) unrelevant preperations
msgrcv(mq_id, m_message, sizeof(MessageBuffer) - sizeof(long), RECEIVER, 0);

in here RECEIVER is my process's mq code, no other processes but RECEIVER receives messages from queue which tagged with type = RECEIVER..

but at posix message queues no such message flags exists, for example at mq_receive:

Code:


mq_receive(mq_id, (char*)m_message, sizeof(MessageBuffer),0);

Sometimes even sender process receives messages more quickly than target process so messaging fails.


How can I distinguish those different processes from each other on a linux system? Any idea?

Thanks


All times are GMT -5. The time now is 03:24 PM.