I am using msgrcv() to read messages from a queue. There are multiple threads, each handling its own message type from a common queue. Lets say there are 3 threads handling message type A, B and C respectively as below: `
thread1()
{
msg_t msg;
while(1)
{
msgrcv(qid, msg, sizeof(msg), A, 0)
.
.
}
}
.
.
thread2()
{
msg_t msg;
while(1)
{
msgrcv(qid, msg, sizeof(msg), B, 0)
.
.
}
}
.
.
thread3()
{
msg_t msg;
while(1)
{
msgrcv(qid, msg, sizeof(msg), C, 0)
.
.
}
}
`
Now I want a fourth thread that can receive all the messages except these three. Can it be achieved using MSG_EXCEPT flag?
Thanks.
I dont know how to use 'MSG_EXCEPT' flag to exclude multiple message types at once.
No, it can't. Instead, provided that you can arrange A, B and C to be greater than all other used message types, you can achieve the goal by specifying the negative of a msgtyp less than A, B and C.