excluding multiple message using MSG_EXCEPT at once in msgrcv()

55 views Asked by At

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.

1

There are 1 answers

3
Armali On BEST ANSWER

Can it be achieved using MSG_EXCEPT flag?

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.