简体   繁体   中英

excluding multiple message using MSG_EXCEPT at once in msgrcv()

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM