Xenomai 进程间通信方式

2023-10-10 06:32

本文主要是介绍Xenomai 进程间通信方式,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

Xenomai 进程间通信方式分成Xenomai域内的IPC以及Xenomai域和Linux域之间的IPC,

目前采用的rtipc(RTDM驱动)的方式,主要是给用户空间提供socket接口,实时应用

通过调用对应的接口可以避免切换到Linux域而导致实时性降低。rtipc对应了三个协议:

XDDP (Xenomai域和Linux域之间的IPC)

IDDP和BUFP (Xenomai域内的IPC)

另外,原有的RT_PIPE机制仍旧支持,但从Xenomai 3开始就不支持了。

http://www.xenomai.org/pipermail/xenomai/2009-September/017631.html

In the wake of a recent discussion about Xenomai 3, the requirement to
find a substitute for the native message pipes interface (i.e. RT_PIPE)
was pointed out.The real-time side of this new interface would have to be available from
kernel space to RTDM drivers as well, so that people adopting a clean
split model like RTDM-drivers <-> userland applications, would not be
left in the cold, with no replacement for the legacy RT_PIPE API in
kernel space, which will be phased out in Xenomai 3.This question, and a few others, may have found an answer with the
recent merging of the so-called RTIPC framework, for Xenomai 2.5.x.
RTIPC is an RTDM-based "meta-driver", on top of which one may stack
protocol drivers, exporting a socket interface to the real-time users,
running in primary mode within the Xenomai domain. The point of RTIPC
being precisely that such users won't want to leave the real-time mode
for sending/receiving data to/from other destinations/sources.So far, I have merged three protocols along with the RTIPC framework,
namely XDDP, IDDP and BUFP.* XDDP stands for "cross-domain datagram protocol", i.e. to exchange
datagrams between the Xenomai (primary) real-time domain, and the Linux
realm. This is what the message pipe fans may want to have a look at.
Basically, it connects a real-time RTDM socket to one of the /dev/rtp*
pseudo-devices. The network port used on the socket side matches the
minor device number used on the non RT side. The added bonus of XDDP is
that people relying on the POSIX skin may now have access to the message
pipe feature, without dragging in bits of the native skin API for that
purpose.* IDDP stands for "intra-domain datagram protocol", i.e. a
Xenomai-to-Xenomai real-time datagram channel. This protocol may not be
as flexible as POSIX message queues (does not support message priority
but does out-of-bound sending though), but exports a socket interface,
which is surely better for your brain than mq_*() (ask Gilles). The
basic idea behind it is that anything you could do based on AF_UNIX
sockets in the Linux realm, should be (mostly) doable with AF_RTIPC+IDDP
in the Xenomai domain. However, we use numeric port numbers or label
strings, and not socket paths to bind sockets in the Xenomai namespace.* BUFP stands for "buffer protocol", probably the most naive of all, but
likely the best fit when you don't care for message boundaries, and just
want an efficient IPC to send a byte stream from a producer to a
consumer thread, without leaving the Xenomai domain. This protocol is
the exact equivalent of the RT_BUFFER API that came to light earlier in
the 2.5.x series, but again, exporting a socket interface to the
real-time application.The fact that all RTIPC protocols are RTDM-based, means that one can
reach the socket API from kernel space as well, using the inter-driver
RTDM interface, see:
http://www.xenomai.org/documentation/xenomai-head/html/api/index.html

参考示例:

http://www.rts.uni-hannover.de/xenomai/lxr/source/examples/rtdm/profiles/ipc/

 * Real-time Xenomai threads and regular Linux threads may want to
 * exchange data in a way that does not require the former to leave
 * the real-time domain (i.e. secondary mode). Message pipes - as
 * implemented by the RTDM-based XDDP protocol - are provided for this
 * purpose.
 *
 * On the Linux domain side, pseudo-device files named /dev/rtp<minor>
 * give regular POSIX threads access to non real-time communication
 * endpoints, via the standard character-based I/O interface. On the
 * Xenomai domain side, sockets may be bound to XDDP ports, which act
 * as proxies to send and receive data to/from the associated
 * pseudo-device files. Ports and pseudo-device minor numbers are
 * paired, meaning that e.g. port 7 will proxy the traffic for
 * /dev/rtp7. Therefore, port numbers may range from 0 to
 * CONFIG_XENO_OPT_PIPE_NRDEV - 1.
 *
 * All data sent through a bound/connected XDDP socket via sendto(2) or
 * write(2) will be passed to the peer endpoint in the Linux domain,
 * and made available for reading via the standard read(2) system
 * call. Conversely, all data sent using write(2) through the non
 * real-time endpoint will be conveyed to the real-time socket
 * endpoint, and made available to the recvfrom(2) or read(2) system
 * calls.

其他相关的说明:

https://www.mail-archive.com/xenomai@xenomai.org/msg04535.html

XDDP is a wrapper over Xenomai's message pipe support, offering a socket-based interface to applications. Each XDDP port is mapped to a given /dev/rtp device minor, but the communication endpoints between RT and NRT are different internally.

[XDDP-port] <---> xnpipe #<port>^||  * input queue:  /dev/rtp -> xnpipe|  * output queue: xnpipe -> /dev/rtp|v/dev/rtp<port>
So, when NRT reads from /dev/rtp<port>, it does not actually listen to the same endpoint/queue than RT, because message pipes are bi-directional. Likewise, NRT and RT never write to the same queue, since the purpose of message pipes is to cross the RT/NRT domain boundary. 


这篇关于Xenomai 进程间通信方式的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/178639

相关文章

Android实现定时任务的几种方式汇总(附源码)

《Android实现定时任务的几种方式汇总(附源码)》在Android应用中,定时任务(ScheduledTask)的需求几乎无处不在:从定时刷新数据、定时备份、定时推送通知,到夜间静默下载、循环执行... 目录一、项目介绍1. 背景与意义二、相关基础知识与系统约束三、方案一:Handler.postDel

gradle第三方Jar包依赖统一管理方式

《gradle第三方Jar包依赖统一管理方式》:本文主要介绍gradle第三方Jar包依赖统一管理方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录背景实现1.顶层模块build.gradle添加依赖管理插件2.顶层模块build.gradle添加所有管理依赖包

Linux之systemV共享内存方式

《Linux之systemV共享内存方式》:本文主要介绍Linux之systemV共享内存方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录一、工作原理二、系统调用接口1、申请共享内存(一)key的获取(二)共享内存的申请2、将共享内存段连接到进程地址空间3、将

Maven中引入 springboot 相关依赖的方式(最新推荐)

《Maven中引入springboot相关依赖的方式(最新推荐)》:本文主要介绍Maven中引入springboot相关依赖的方式(最新推荐),本文给大家介绍的非常详细,对大家的学习或工作具有... 目录Maven中引入 springboot 相关依赖的方式1. 不使用版本管理(不推荐)2、使用版本管理(推

C#使用StackExchange.Redis实现分布式锁的两种方式介绍

《C#使用StackExchange.Redis实现分布式锁的两种方式介绍》分布式锁在集群的架构中发挥着重要的作用,:本文主要介绍C#使用StackExchange.Redis实现分布式锁的... 目录自定义分布式锁获取锁释放锁自动续期StackExchange.Redis分布式锁获取锁释放锁自动续期分布式

Java对象转换的实现方式汇总

《Java对象转换的实现方式汇总》:本文主要介绍Java对象转换的多种实现方式,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友参考下吧... 目录Java对象转换的多种实现方式1. 手动映射(Manual Mapping)2. Builder模式3. 工具类辅助映

Spring Boot读取配置文件的五种方式小结

《SpringBoot读取配置文件的五种方式小结》SpringBoot提供了灵活多样的方式来读取配置文件,这篇文章为大家介绍了5种常见的读取方式,文中的示例代码简洁易懂,大家可以根据自己的需要进... 目录1. 配置文件位置与加载顺序2. 读取配置文件的方式汇总方式一:使用 @Value 注解读取配置方式二

JAVA保证HashMap线程安全的几种方式

《JAVA保证HashMap线程安全的几种方式》HashMap是线程不安全的,这意味着如果多个线程并发地访问和修改同一个HashMap实例,可能会导致数据不一致和其他线程安全问题,本文主要介绍了JAV... 目录1. 使用 Collections.synchronizedMap2. 使用 Concurren

Python如何精准判断某个进程是否在运行

《Python如何精准判断某个进程是否在运行》这篇文章主要为大家详细介绍了Python如何精准判断某个进程是否在运行,本文为大家整理了3种方法并进行了对比,有需要的小伙伴可以跟随小编一起学习一下... 目录一、为什么需要判断进程是否存在二、方法1:用psutil库(推荐)三、方法2:用os.system调用

C# foreach 循环中获取索引的实现方式

《C#foreach循环中获取索引的实现方式》:本文主要介绍C#foreach循环中获取索引的实现方式,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友参考下吧... 目录一、手动维护索引变量二、LINQ Select + 元组解构三、扩展方法封装索引四、使用 for 循环替代