如何保持阻塞状态以阅读消息队列?
消息队列发件人由多计数器启动。消息队列标志正在阻止。我不能使用循环从消息队列中读取消息,因为它需要太多资源。有什么方法可以让我的功能在消息队列中有消息后立即调用MSGRCV()读取消息。感谢您的建议和答案!我们在我们的程序中使用MSGGET 、MSGCTL 、MSGSND、MSGSND。
for(;;){
msglen = msgrcv(serverId,&req, REQ_MSG_SIZE,0,0);
if (msgLen ==-1){
errMsg("msgrcv");
break;
}
...
}
在这里,我用来连续调用MSGRCV函数以读取消息队列中的消息。CPU使用率将达到100%。这是我不使用循环的一种方式,当消息队列带有消息MSGRCV并阅读消息时。
The message queue sender is started by a multi-timer. The message queue flag is blocking. I can't use a loop to read messages from the message queue because it takes too much resources. Is there any way that my function can call the msgrcv() to read the message as soon as there is a message in the message queue.Thanks a lot for your suggestions and answers! we use msgget、msgctl、msgsnd、msgrcv in our programm.
for(;;){
msglen = msgrcv(serverId,&req, REQ_MSG_SIZE,0,0);
if (msgLen ==-1){
errMsg("msgrcv");
break;
}
...
}
Here I use for to continuously call the msgrcv function to read the messages in the message queue.The cpu usage will reach 100%. is here a way for me to not use a for loop, when the message queue has a message msgrcv will be called and read the message.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论