QNX Interprocess Communication

Definition

DefinitionDescription描述
nodeThe node descriptor of the node (e.g., ND_LOCAL_NODE for the local node) on which the process that owns the channel is running拥有channel的进程正在运行的节点的节点描述符(例如,本地节点的 ND_LOCAL_NODE)
coidThe ID of the connection to the channel to send the message on, which you’ve established by calling ConnectAttach()连接到channel的connection的ID
pidThe process ID of the owner of the channel.拥有channel的进程的ID
chidThe channel ID, returned by ChannelCreate(), of the channel to connect to the process.要连接到进程的channel的channel ID, 由ChannelCreate()返回
rcvidThe receive ID that MsgReceive*() returned when you received the message.MsgReceive*() 返回的接收 ID

Client->node->pid->chid

Message-passing API

FunctionDescription描述
MsgSend()Send a message and block until reply.发送一个消息,在reply之前一直block
MsgReceive()Wait for a message.等待一个消息
MsgReceivePulse()Wait for a tiny, nonblocking message (pulse).等待一个微小的、非阻塞的消息(脉冲)
MsgReply()Reply to a message.应答一个消息
MsgError()Reply only with an error status. No message bytes are transferred.只回复错误状态,不传输消息字节
MsgRead()Read additional data from a received message.从收到的消息中读取附加数据
MsgWrite()Write additional data to a reply message.将附加数据写入应答消息
MsgInfo()Obtain info on a received message.获取收到的消息的信息
MsgSendPulse()Send a tiny, nonblocking message (pulse).发送一个微小的、非阻塞的消息(脉冲)
MsgDeliverEvent()Deliver an event to a client.将一个事件传递给一个客户端
MsgKeyData()Key a message to allow security checks.键入消息以允许安全检查

Channels and Connections

在 QNX Neutrino RTOS 中,消息传递是针对channel和connection的,而不是直接从线程到线程。
在这里插入图片描述
Server: 服务端使用channel来发送 MsgReceive() 消息。
Client: 客户端线程创建connection以“连接”到服务端提供的channel。
channel和connection在进程中由一个小的整数标识符命名。 客户端连接直接映射到文件描述符(FD)。

Send, Receive and Reply

客户端

    ConnectionId = ConnectAttach(Node, Pid, Chid, Index, Flag);
    MsgSend(ConnectionId, SendBuf, SendLen, ReplyBuf, ReplyLen);
    (... 由OS将这个线程挂起 ...)
    (... 当服务器MsgReply()后,OS解除线程的阻塞状态, 客户端可以检查自己的ReceiveBuf 看看应答结果 ...)

服务端

    ChannelId = ChannelCreate(Flags);
    ReceiveId = MsgReceive(ChannelId, ReceiveBuffer, ReceiveBufLength, &MsgInfo);
    header = (struct header *)ReceiveBUffer;
    databuf = (char *)((char *)header + sizeof(*header));
    (... 检查Buffer里的消息进行处理 ...)
    MsgReply(ReceiveId, ReplyStatus, ReplyBuf, ReplyLen);

Note: 在QNX中可以使用pidin查看线程、进程状态。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值