怎样在程序中修改一个系统V消息队列中消息的个数::
时间:2011-05-23
来源:互联网
如题:想通过程序中的系统调用修改一个消息队列中消息的个数:
例如:megctl(msqid,IPC_SET,msqid_ds*buf);
但是;书上说只能修改msqid_ds结构中的四个字段:msg _perm.uid、msg_perm_gid、msgg_perm .mode和msg_perm.qbytes.
具体怎样设置??高人出手!!!
例如:megctl(msqid,IPC_SET,msqid_ds*buf);
但是;书上说只能修改msqid_ds结构中的四个字段:msg _perm.uid、msg_perm_gid、msgg_perm .mode和msg_perm.qbytes.
具体怎样设置??高人出手!!!
作者: moye112 发布时间: 2011-05-23
查手册。
我经常用"www.die.net"查函数。
C/C++ code
IPC_SET
Write the values of some members of the msqid_ds structure pointed to by buf to the kernel data structure associated with this message queue, updating also its msg_ctime member. The following members of the structure are updated: msg_qbytes, msg_perm.uid, msg_perm.gid, and (the least significant 9 bits of) msg_perm.mode. The effective UID of the calling process must match the owner (msg_perm.uid) or creator (msg_perm.cuid) of the message queue, or the caller must be privileged. Appropriate privilege (Linux: the CAP_IPC_RESOURCE capability) is required to raise the msg_qbytes value beyond the system parameter MSGMNB.
确定你的消息大小,把msg_qbytes设置为“消息大小*消息个数”
我经常用"www.die.net"查函数。
C/C++ code
struct msqid_ds { struct ipc_perm msg_perm; /* Ownership and permissions time_t msg_stime; /* Time of last msgsnd() */ time_t msg_rtime; /* Time of last msgrcv() */ time_t msg_ctime; /* Time of last change */ unsigned long __msg_cbytes; /* Current number of bytes in queue (non-standard) */ msgqnum_t msg_qnum; /* Current number of messages in queue */ msglen_t msg_qbytes; /* Maximum number of bytes allowed in queue */ pid_t msg_lspid; /* PID of last msgsnd() */ pid_t msg_lrpid; /* PID of last msgrcv() */ };
IPC_SET
Write the values of some members of the msqid_ds structure pointed to by buf to the kernel data structure associated with this message queue, updating also its msg_ctime member. The following members of the structure are updated: msg_qbytes, msg_perm.uid, msg_perm.gid, and (the least significant 9 bits of) msg_perm.mode. The effective UID of the calling process must match the owner (msg_perm.uid) or creator (msg_perm.cuid) of the message queue, or the caller must be privileged. Appropriate privilege (Linux: the CAP_IPC_RESOURCE capability) is required to raise the msg_qbytes value beyond the system parameter MSGMNB.
确定你的消息大小,把msg_qbytes设置为“消息大小*消息个数”
作者: zhaokai3000 发布时间: 2011-05-24
貌似msgctl不能修改消息个数,只有消息队列容量
可以通过调整内核参数的方式调整消息个数
MSGSEG 在单个队列里能存在的最大数量的消息片断。
参考Linux IPC 参数设定
可以通过调整内核参数的方式调整消息个数
MSGSEG 在单个队列里能存在的最大数量的消息片断。
参考Linux IPC 参数设定
作者: justkk 发布时间: 2011-05-24
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28