免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 8184 | 回复: 5
打印 上一主题 下一主题

关于POSIX消息队列,不被支持的问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-09-19 10:17 |只看该作者 |倒序浏览
在我的目标系统上(内核2.6.30 glibc 2.5-cs4.1-176),使用mq_open时(POSIX消息队列打开函数) ,提示“Function not implemented”.
我查看了/proc,也没有/proc/sys/fs/mqueue目录。
我该怎么做才能让目标系统支持POSIX消息队列呢?
重新编译内核?
实验代码如下:

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>

  4. #include <unistd.h>
  5. #include <pthread.h>
  6. #include <mqueue.h>

  7. #include <limits.h>
  8. #include <fcntl.h>
  9. #include <sys/stat.h>

  10. #define FILE_MODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)

  11. int main(void)
  12. {
  13.         int err;
  14.         mqd_t mqd;

  15.         mqd = mq_open("/mq01", O_CREAT | O_RDWR, FILE_MODE, NULL);
  16.         if(mqd  == (mqd_t)-1)
  17.         {
  18.                 perror("mq_open");
  19.         }else{
  20.                 printf("mq_open: success\n");
  21.                 err = mq_unlink("/mq01");
  22.                 if(err == 0){
  23.                         printf("mq_unlink: success.\n");
  24.                 }
  25.         }

  26.         printf("message queue end\n");
  27.         return 0;
  28. }
复制代码

论坛徽章:
0
2 [报告]
发表于 2011-09-19 10:31 |只看该作者
补充:
1 在内核源码目录执行下面命令:
#grep POSIX ./config
输出如下:
CONFIG_FS_POSIX_ACL=y

2在make numuconfig的General setup--->下,没找到与POSIX相关的选项

  1. [ ] Prompt for development and/or incomplete code/drivers         
  2. ()  Local version - append to kernel release                     
  3. [ ] Automatically append version information to the version string
  4. [ ] Support for paging of anonymous memory (swap)                 
  5. [*] System V IPC                                                  
  6. [*] BSD Process Accounting                                       
  7. [ ]   BSD Process Accounting version 3 file format               
  8. [ ] Export task/process statistics through netlink (EXPERIMENTAL)
  9. [ ] Auditing support                                             
  10.     RCU Subsystem  --->                                          
  11. < > Kernel .config support                                       
  12. (14) Kernel log buffer size (16 => 64KB, 17 => 128KB)            
  13. [ ] Control Group support  --->                                   
  14. [ ] Create deprecated sysfs layout for older userspace tools      
  15. [ ] Kernel->user space relay support (formerly relayfs)           
  16. [ ] Namespaces support                                            
  17. [*] Initial RAM filesystem and RAM disk (initramfs/initrd) support
  18. ()    Initramfs source file(s)                                    
  19. [*]   Support initial ramdisks compressed using gzip              
  20. [ ]   Support initial ramdisks compressed using bzip2            
  21. [ ]   Support initial ramdisks compressed using LZMA              
  22. [ ] Optimize for size                                             
  23. -*- Configure standard kernel features (for small systems)  --->  
  24. [ ] Strip assembler-generated symbols during link                 
  25. [*] Support for hot-pluggable devices                             
  26. [*] Enable support for printk                                    
  27. [*] BUG() support                                                
  28. [ ] Enable ELF core dumps                                         
  29. [*] Enable full-sized data structures for core                    
  30. [*] Enable futex support                                          
  31. [ ] Enable eventpoll support                                      
  32. [ ] Enable signalfd() system call                                 
  33. [ ] Enable timerfd() system call                                 
  34. [ ] Enable eventfd() system call                                 
  35. [ ] Use full shmem filesystem                                    
  36. [*] Enable AIO support                                            
  37. [*] Enable VM event counters for /proc/vmstat                     
  38. [*] Disable heap randomization                                    
  39.     Choose SLAB allocator (SLAB)  --->                           
  40. [ ] Profiling support (EXPERIMENTAL)                              
  41. [ ] Activate markers  
复制代码

论坛徽章:
0
3 [报告]
发表于 2011-09-19 10:33 |只看该作者
再补充:
同样的代码,在我的PC(FC 10,内核2.6.27.5-117)上,能正常运行。

论坛徽章:
95
程序设计版块每日发帖之星
日期:2015-09-05 06:20:00程序设计版块每日发帖之星
日期:2015-09-17 06:20:00程序设计版块每日发帖之星
日期:2015-09-18 06:20:002015亚冠之阿尔艾因
日期:2015-09-18 10:35:08月度论坛发贴之星
日期:2015-09-30 22:25:002015亚冠之阿尔沙巴布
日期:2015-10-03 08:57:39程序设计版块每日发帖之星
日期:2015-10-05 06:20:00每日论坛发贴之星
日期:2015-10-05 06:20:002015年亚冠纪念徽章
日期:2015-10-06 10:06:482015亚冠之塔什干棉农
日期:2015-10-19 19:43:35程序设计版块每日发帖之星
日期:2015-10-21 06:20:00每日论坛发贴之星
日期:2015-09-14 06:20:00
4 [报告]
发表于 2011-09-19 11:23 |只看该作者
我该怎么做才能让目标系统支持POSIX消息队列呢?
kaolacatty 发表于 2011-09-19 10:17



    看看有没有下述选项,有的话打开试试:

  1. $ grep -i mqueue config-2.6.32-5-amd64
  2. CONFIG_POSIX_MQUEUE=y
  3. CONFIG_POSIX_MQUEUE_SYSCTL=y
复制代码

论坛徽章:
0
5 [报告]
发表于 2011-09-19 11:39 |只看该作者

  1. #grep -i mqueue .config
复制代码
没找到任何宏

  1. #grep -i posix .config
  2. CONFIG_POSIX_ACL=y
复制代码
只有这一个输出

论坛徽章:
0
6 [报告]
发表于 2011-09-20 11:42 |只看该作者
问题解决了,还是内核配置的问题。
General setup--->PROMPT FOR DEVELOPMENT AND/OR INCOMPLETE CODE/DRIVERS如果不选择的话,General setup--->POSIX Message Queues选项没有显示。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP