uClinux 上 使用 msgget, msgsnd, msgrcv 问题

property1 2006-09-04 05:56:57
uClinux 上,

代码如下


#define BRCBRPT_MSGQ_ID 'a'
int m_brcbRptMsgQ;
int main()
{
unsigned int threadId;
unsigned char buf[16];
/*创建消息队列*/

if ((m_brcbRptMsgQ =
msgget (ftok (".", BRCBRPT_MSGQ_ID), IPC_CREAT | IPC_EXCL)) == -1)
{
if ((m_brcbRptMsgQ =
msgget (ftok (".", BRCBRPT_MSGQ_ID), IPC_CREAT)) == -1)
{
perror ("msgget") ;
exit (1) ;
}
msgctl (m_brcbRptMsgQ, IPC_RMID, 0) ;
if ((m_brcbRptMsgQ =
msgget (ftok (".", BRCBRPT_MSGQ_ID), IPC_CREAT | IPC_EXCL))
== -1)
{
perror ("msgget") ;
exit (1) ;
}
}
/*发送消息*/
if (msgsnd (m_brcbRptMsgQ, (struct msgbuf *)buf,
sizeof (buf) - sizeof (long), IPC_NOWAIT) == -1)
{
printf ("msgsnd : error !\n") ;
return 1;
}
printf("hello!\n");
return 0;
}




编译通过,

文件系统, 下到板子中,
运行,
>/hello

光标 一直停在 ">/hello" 的下一行 , 不动, 没有打印出 "hello!"


请问 uClinux 上 无法 使用 msgget 等 吗?
还是 需要在编译内核时,设置?
如果 不能使用 msgget 等, 请问,用什么方法替代?


还有, 那位高人 介绍 一些 uClinux 的资料, 配置, 编译 内核,文件系统, uClinux 上 编程的 资料, 不胜感激!







...全文
603 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
MaxXu0905 2006-09-11
  • 打赏
  • 举报
回复
很有可能不能使用,毕竟msgget跟操作系统关系非常密切。
对uClinux不是很懂,看能不能通过文件传消息喽
amingo 2006-09-10
  • 打赏
  • 举报
回复
帮LZ顶 LZ加油
property1 2006-09-05
  • 打赏
  • 举报
回复
谢谢 yjf7888()急需专家分()

放到 前面也不行, 没有打印出 hello


忘了说一点 :
make user_only 时
提示
ERROR: Section not code.
yjf7888 2006-09-05
  • 打赏
  • 举报
回复
把printf("hello!\n");
放到if ((m_brcbRptMsgQ =
msgget (ftok (".", BRCBRPT_MSGQ_ID), IPC_CREAT | IPC_EXCL)) == -1)
前面试试。

http://www.dz863.com/RTOS/uClinux.htm
http://www.autocontrol.com.cn/book/doc/04.03/37.doc
http://www.wlcbnews.com/BBS/Browers.aspx?QID=2535&Page=1
property1 2006-09-05
  • 打赏
  • 举报
回复
up
property1 2006-09-04
  • 打赏
  • 举报
回复
up

23,125

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧