QNX中进程间通信(IPC)之Connection篇

操作系统实战解剖:从开机引导到UI渲染的五层架构 操作系统是管理硬件资源与提供程序运行环境的核心系统软件,其本质是一套协同工作的内核调度、内存管理、设备驱动和安全控制机制。理解它需跳出UI表象,深入固件(BIOS/UEFI)、引导加载器(GRUB/boot.efi)、内核初始化(Linux systemd/macOS XNU)、用户空间服务(Display Server/Wayland)及应用交互(系统调用syscall)这五层真实启动链。技术价值在于支撑跨平台兼容性、实时性保障与安全隔离——如WSL2依赖Hyper-V虚拟化,macOS驱动授权源于IOK 阅读详情

主要内容翻译自QNX开发文档,根据自己理解翻译,错误之处在所难免,目的还是提供给大家对照阅读,我自己也写了一些代码,抽空后继也会放上

 

<!-- /* Font Definitions */ @font-face {font-family:Wingdings; panose-1:5 0 0 0 0 0 0 0 0 0; mso-font-charset:2; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:0 268435456 0 0 -2147483648 0;} @font-face {font-family:宋体; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:SimSun; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:1; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:0 0 0 0 0 0;} @font-face {font-family:Cambria; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:0; mso-generic-font-family:roman; mso-font-pitch:variable; mso-font-signature:-1610611985 1073741899 0 0 159 0;} @font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:-1610611985 1073750139 0 0 159 0;} @font-face {font-family:"/@宋体"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-unhide:no; mso-style-qformat:yes; mso-style-parent:""; margin:0cm; margin-bottom:.0001pt; text-align:justify; text-justify:inter-ideograph; text-indent:10.0pt; mso-char-indent-count:2.0; line-height:150%; mso-pagination:none; font-size:12.0pt; mso-bidi-font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:宋体; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi; mso-font-kerning:1.0pt;} h2 {mso-style-priority:9; mso-style-qformat:yes; mso-style-link:"标题 2 Char"; mso-style-next:正文; margin-top:13.0pt; margin-right:0cm; margin-bottom:13.0pt; margin-left:0cm; text-align:justify; text-justify:inter-ideograph; text-indent:10.0pt; mso-char-indent-count:2.0; line-height:173%; mso-pagination:lines-together; page-break-after:avoid; mso-outline-level:2; font-size:16.0pt; font-family:"Cambria","serif"; mso-ascii-font-family:Cambria; mso-ascii-theme-font:major-latin; mso-fareast-font-family:宋体; mso-fareast-theme-font:major-fareast; mso-hansi-font-family:Cambria; mso-hansi-theme-font:major-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:major-bidi; mso-font-kerning:1.0pt;} a:link, span.MsoHyperlink {mso-style-priority:99; color:blue; mso-themecolor:hyperlink; text-decoration:underline; text-underline:single;} a:visited, span.MsoHyperlinkFollowed {mso-style-noshow:yes; mso-style-priority:99; color:purple; mso-themecolor:followedhyperlink; text-decoration:underline; text-underline:single;} p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph {mso-style-priority:34; mso-style-unhide:no; mso-style-qformat:yes; margin:0cm; margin-bottom:.0001pt; text-align:justify; text-justify:inter-ideograph; text-indent:21.0pt; mso-char-indent-count:2.0; line-height:150%; mso-pagination:none; font-size:12.0pt; mso-bidi-font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:宋体; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi; mso-font-kerning:1.0pt;} span.2Char {mso-style-name:"标题 2 Char"; mso-style-priority:9; mso-style-unhide:no; mso-style-locked:yes; mso-style-link:"标题 2"; mso-ansi-font-size:16.0pt; mso-bidi-font-size:16.0pt; font-family:"Cambria","serif"; mso-ascii-font-family:Cambria; mso-ascii-theme-font:major-latin; mso-fareast-font-family:宋体; mso-fareast-theme-font:major-fareast; mso-hansi-font-family:Cambria; mso-hansi-theme-font:major-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:major-bidi; font-weight:bold;} .MsoChpDefault {mso-style-type:export-only; mso-default-props:yes; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi;} /* Page Definitions */ @page {mso-page-border-surround-header:no; mso-page-border-surround-footer:no;} @page Section1 {size:612.0pt 792.0pt; margin:72.0pt 90.0pt 72.0pt 90.0pt; mso-header-margin:36.0pt; mso-footer-margin:36.0pt; mso-paper-source:0;} div.Section1 {page:Section1;} /* List Definitions */ @list l0 {mso-list-id:197359659; mso-list-type:hybrid; mso-list-template-ids:-1428798694 67698705 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;} @list l0:level1 {mso-level-text:"%1/)"; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:45.0pt; text-indent:-21.0pt;} @list l1 {mso-list-id:268320517; mso-list-type:hybrid; mso-list-template-ids:-851309630 67698689 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;} @list l1:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:45.0pt; text-indent:-21.0pt; font-family:Wingdings;} @list l2 {mso-list-id:811946332; mso-list-type:hybrid; mso-list-template-ids:-652734772 67698705 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;} @list l2:level1 {mso-level-text:"%1/)"; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:45.0pt; text-indent:-21.0pt;} @list l3 {mso-list-id:959872210; mso-list-type:hybrid; mso-list-template-ids:-1328881422 67698689 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;} @list l3:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:45.0pt; text-indent:-21.0pt; font-family:Wingdings;} @list l4 {mso-list-id:1010639450; mso-list-template-ids:67698717;} @list l4:level1 {mso-level-text:%1; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:21.25pt; text-indent:-21.25pt;} @list l4:level2 {mso-level-text:"%1/.%2"; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:49.6pt; text-indent:-1.0cm;} @list l4:level3 {mso-level-text:"%1/.%2/.%3"; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:70.9pt; text-indent:-1.0cm;} @list l4:level4 {mso-level-text:"%1/.%2/.%3/.%4"; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:99.2pt; text-indent:-35.4pt;} @list l4:level5 {mso-level-text:"%1/.%2/.%3/.%4/.%5"; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:127.55pt; text-indent:-42.5pt;} @list l4:level6 {mso-level-text:"%1/.%2/.%3/.%4/.%5/.%6"; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:163.0pt; text-indent:-2.0cm;} @list l4:level7 {mso-level-text:"%1/.%2/.%3/.%4/.%5/.%6/.%7"; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:191.35pt; text-indent:-63.8pt;} @list l4:level8 {mso-level-text:"%1/.%2/.%3/.%4/.%5/.%6/.%7/.%8"; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:219.7pt; text-indent:-70.9pt;} @list l4:level9 {mso-level-text:"%1/.%2/.%3/.%4/.%5/.%6/.%7/.%8/.%9"; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:255.1pt; text-indent:-85.0pt;} @list l5 {mso-list-id:1488595309; mso-list-type:hybrid; mso-list-template-ids:-812772426 67698689 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;} @list l5:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:45.0pt; text-indent:-21.0pt; font-family:Wingdings;} ol {margin-bottom:0cm;} ul {margin-bottom:0cm;} -->

使用某个对象建立连接的进程我们称之为 connector , connector 是 server 创建、拥有并供 client 连接上的名称。 Connector 仅被用来建立连接。

Connector 有一个数字形式的 ID 和一个相关联的名称,并且该名称和 ID 在其所在的 Photon session 中是唯一的,以下是可以使用名称的几种情况:

l  Server 启动时,创建一个带有约定名称的 connector( 如下面例子中的 Helpviewer) 。 Client 连接到该 connector 、发送请求,然后关闭连接。如果 client 查找名称过程失败,将会自动创建 server 并且重试。

l  Server 创建一个匿名 connector 并且以某种方式发送 connector 的 ID 到潜在的 client 对象 ( 拖拽事件使用这种方式 ) 。 Client 之后使用这个 ID 连接 server 。

l  如果 client 在 server 运行时又需要创建一些 server 供自己使用,可以使用 PtConnectionTmpName() 函数来创建一个“临时 connector 名称”并且通过命令行方式或者系统环境变量方式传递给 server ,之后连接上去。

1.1     Naming conventions

应该使用以下命名约定来定义 connector 的唯一名称:

l  名称中不得包含被 QNX 软件系统保留的斜线。

l  第三方产品应该以一个唯一字符串 ( 例如电子邮件地址或域名 ) 后跟随斜线加名称的方式,例如 www.acme.com/dbmanager 。

1.2     典型实例

以下是使用 connection 的典型实例:

1)        Server 调用 PtConnectorCreate() 来设置一个 connector ,指定 client 连接上 connector 的时候将回调哪一个函数。

2)        如果 client 需要一个 connector ID 来找到 connector , server 需要调用 PtConnectorGetId() 来获取这个 ID ,并在以后需要时将这个 ID 传递给 client 。

3)        Client 通过调用 PtConnectionFindName() 或 PtConnectionFindId() 函数来查询 connector ,如果函数执行成功将返回一个 PtConnectionClient_t 类型的 client connection 对象。 Client 也可以通过调用 PtConnectionWaitForName() 函数来尝试重复查找 server( 在指定限制时间内或直到 server 中止 ) 。

4)        如果 client 找到 connector ,此时 library 将会对连接进行设置并且调用 server 指定的回调函数,同时传递 PtConnectionServer_t 类型的 server connection 对象到回调函数中。

5)        Server 回调函数使用 PtConnectionAddMsgHandlers() 来设置客户端传送消息的 handler( 处理函数 ) 。

6)        Client 使用 PtConnectionSend() 或 PtConnectionSendmx() 来发送消息,同时阻塞,直到 Server 回复。

7)        Server 对消息进行处理,并调用 PtConnectionReply() 或 PtConnectionReplymx() 回复 client 。

8)        Client 和 server 继续执行并进行消息传递。

9)        如果 Client 想中断连接,调用 PtConnectionClientDestroy() ;如果是 Server ,调用 PtConnectionServerDestroy() 。

10)    当 server 不需要 connector 的时候可以调用 PtConnectorDestroy() 销毁。

可以使用在消息传送 connection 中夹带数据。 Server 调用 PtConnectionServerSetUserData() 来指定 Client 可通过调用 PtConnectionClientGetUserData() 获取的数据,同理, Client 调用 PtConnectionClientSetUserData() 来设置 Server 可通过调用 PtConnectionServerGetUserData() 获取的数据。

Server 端通过 PtConnectionServerSetError() 设置错误处理函数, Client 端通过 PtConnectionClientSetError() 设置。

Server 也可以通过事件来通知 Client :

1)        客户端通过 PtConnectionAddEventHandlers() 设置一个或多个消息处理函数,可以对不同消息类型分别进行处理。

2)        Server 可以通过调用 PtConnectionNotify() 发送事件通知,该函数在 server 自身 buffer 空间不够的时候通过轮流调用 PtConnectionFlush() 来处理。

3)        Server 可以通过 PtConnectionResizeEventBuffer() 改变缓冲区大小。

1.3     Local Connections

某些情况下你可能需要对某个进程创建一个自连接,这种情况下与标准的连接略有不同:

l  对于标准连接, PtConnectionSend() 、 PtConnectionSendmx() 和 PtConnectionNotify() 函数发送一个消息 (message) 或是脉冲 (pulse) ,不执行任何用户代码 (Photon 事件被正常处理导致 PtConnectionNotify() 需要填写缓冲区的情况除外 ) 。

对于本地连接, PtConnectionSend() 、 PtConnectionSendmx() 和 PtConnectionNotify() 直接调用消息处理函数,调用代码和处理必须考虑这样的副作用。

l  另一个不同是处理从不同的上下文调用。通常,一个事件或消息处理源自于一个输入函数,由于输入函数直到代码执行到主循环或 PtBkgdHandlerProcess() 或 PtProcessEvent() 后才会调用,可以假设在回调执行时处理不会调用因此是安全的。但如果 connection 是本地的,处理通过 PtConnectionSend() 、 PtConnectionSendmx() 、 PtConnectionNotify() 直接调用,因此需要做相应修改。

l  另一个副作用是如果消息处理由 PtConnectionNotify() 调用, client 在回复 (reply) 之前得到通知 (notification) ,也就是说, client 的事件处理在 PtConnectionSend() 或 PtConnectionSendmx() 调用返回之前执行;如果这时 PtConnectionSend() 或 PtConnectionSendmx() 再次执行调用返回错误, errno 被设置为 EBUSY ( 这样系统避免了进入死循环 ) 。

简单的避免方法是在消息处理中避免发送通知――作为替代,通知可以放置于回复中。

 

<!-- /* Font Definitions */ @font-face {font-family:宋体; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:SimSun; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:1; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:0 0 0 0 0 0;} @font-face {font-family:Cambria; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:0; mso-generic-font-family:roman; mso-font-pitch:variable; mso-font-signature:-1610611985 1073741899 0 0 159 0;} @font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:-1610611985 1073750139 0 0 159 0;} @font-face {font-family:"/@宋体"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-unhide:no; mso-style-qformat:yes; mso-style-parent:""; margin:0cm; margin-bottom:.0001pt; text-align:justify; text-justify:inter-ideograph; text-indent:10.0pt; mso-char-indent-count:2.0; line-height:150%; mso-pagination:none; font-size:12.0pt; mso-bidi-font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:宋体; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi; mso-font-kerning:1.0pt;} h2 {mso-style-priority:9; mso-style-qformat:yes; mso-style-link:"标题 2 Char"; mso-style-next:正文; margin-top:13.0pt; margin-right:0cm; margin-bottom:13.0pt; margin-left:0cm; text-align:justify; text-justify:inter-ideograph; text-indent:10.0pt; mso-char-indent-count:2.0; line-height:173%; mso-pagination:lines-together; page-break-after:avoid; mso-outline-level:2; font-size:16.0pt; font-family:"Cambria","serif"; mso-ascii-font-family:Cambria; mso-ascii-theme-font:major-latin; mso-fareast-font-family:宋体; mso-fareast-theme-font:major-fareast; mso-hansi-font-family:Cambria; mso-hansi-theme-font:major-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:major-bidi; mso-font-kerning:1.0pt;} span.2Char {mso-style-name:"标题 2 Char"; mso-style-priority:9; mso-style-unhide:no; mso-style-locked:yes; mso-style-link:"标题 2"; mso-ansi-font-size:16.0pt; mso-bidi-font-size:16.0pt; font-family:"Cambria","serif"; mso-ascii-font-family:Cambria; mso-ascii-theme-font:major-latin; mso-fareast-font-family:宋体; mso-fareast-theme-font:major-fareast; mso-hansi-font-family:Cambria; mso-hansi-theme-font:major-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:major-bidi; font-weight:bold;} .MsoChpDefault {mso-style-type:export-only; mso-default-props:yes; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi;} /* Page Definitions */ @page {mso-page-border-surround-header:no; mso-page-border-surround-footer:no;} @page Section1 {size:612.0pt 792.0pt; margin:72.0pt 90.0pt 72.0pt 90.0pt; mso-header-margin:36.0pt; mso-footer-margin:36.0pt; mso-paper-source:0;} div.Section1 {page:Section1;} /* List Definitions */ @list l0 {mso-list-id:1010639450; mso-list-template-ids:67698717;} @list l0:level1 {mso-level-text:%1; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:21.25pt; text-indent:-21.25pt;} @list l0:level2 {mso-level-text:"%1/.%2"; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:49.6pt; text-indent:-1.0cm;} @list l0:level3 {mso-level-text:"%1/.%2/.%3"; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:70.9pt; text-indent:-1.0cm;} @list l0:level4 {mso-level-text:"%1/.%2/.%3/.%4"; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:99.2pt; text-indent:-35.4pt;} @list l0:level5 {mso-level-text:"%1/.%2/.%3/.%4/.%5"; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:127.55pt; text-indent:-42.5pt;} @list l0:level6 {mso-level-text:"%1/.%2/.%3/.%4/.%5/.%6"; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:163.0pt; text-indent:-2.0cm;} @list l0:level7 {mso-level-text:"%1/.%2/.%3/.%4/.%5/.%6/.%7"; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:191.35pt; text-indent:-63.8pt;} @list l0:level8 {mso-level-text:"%1/.%2/.%3/.%4/.%5/.%6/.%7/.%8"; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:219.7pt; text-indent:-70.9pt;} @list l0:level9 {mso-level-text:"%1/.%2/.%3/.%4/.%5/.%6/.%7/.%8/.%9"; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:255.1pt; text-indent:-85.0pt;} ol {margin-bottom:0cm;} ul {margin-bottom:0cm;} -->

1.1     Example

以下例子使用 connector 判断是否有重复执行实例,该实例有两个命令行开关:

-e

如果有实例运行,让他关闭。

-f file

如果有实例运行,让他打开一个指定的文件,否则新实例打开文件。

以下是关键代码:

 

 

 

 

<!-- /* Font Definitions */ @font-face {font-family:宋体; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:SimSun; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:1; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:0 0 0 0 0 0;} @font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:-1610611985 1073750139 0 0 159 0;} @font-face {font-family:"/@宋体"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-unhide:no; mso-style-qformat:yes; mso-style-parent:""; margin:0cm; margin-bottom:.0001pt; text-align:justify; text-justify:inter-ideograph; text-indent:10.0pt; mso-char-indent-count:2.0; line-height:150%; mso-pagination:none; font-size:12.0pt; mso-bidi-font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:宋体; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi; mso-font-kerning:1.0pt;} h1 {mso-style-priority:9; mso-style-unhide:no; mso-style-qformat:yes; mso-style-link:"标题 1 Char"; mso-style-next:正文; margin-top:17.0pt; margin-right:0cm; margin-bottom:16.5pt; margin-left:0cm; text-align:justify; text-justify:inter-ideograph; text-indent:10.0pt; mso-char-indent-count:2.0; line-height:240%; mso-pagination:lines-together; page-break-after:avoid; mso-outline-level:1; font-size:22.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-font-kerning:22.0pt;} span.1Char {mso-style-name:"标题 1 Char"; mso-style-priority:9; mso-style-unhide:no; mso-style-locked:yes; mso-style-link:"标题 1"; mso-ansi-font-size:22.0pt; mso-bidi-font-size:22.0pt; mso-font-kerning:22.0pt; font-weight:bold;} .MsoChpDefault {mso-style-type:export-only; mso-default-props:yes; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi;} /* Page Definitions */ @page {mso-page-border-surround-header:no; mso-page-border-surround-footer:no;} @page Section1 {size:612.0pt 792.0pt; margin:72.0pt 90.0pt 72.0pt 90.0pt; mso-header-margin:36.0pt; mso-footer-margin:36.0pt; mso-paper-source:0;} div.Section1 {page:Section1;} /* List Definitions */ @list l0 {mso-list-id:1010639450; mso-list-template-ids:67698717;} @list l0:level1 {mso-level-text:%1; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:21.25pt; text-indent:-21.25pt;} @list l0:level2 {mso-level-text:"%1/.%2"; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:49.6pt; text-indent:-1.0cm;} @list l0:level3 {mso-level-text:"%1/.%2/.%3"; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:70.9pt; text-indent:-1.0cm;} @list l0:level4 {mso-level-text:"%1/.%2/.%3/.%4"; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:99.2pt; text-indent:-35.4pt;} @list l0:level5 {mso-level-text:"%1/.%2/.%3/.%4/.%5"; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:127.55pt; text-indent:-42.5pt;} @list l0:level6 {mso-level-text:"%1/.%2/.%3/.%4/.%5/.%6"; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:163.0pt; text-indent:-2.0cm;} @list l0:level7 {mso-level-text:"%1/.%2/.%3/.%4/.%5/.%6/.%7"; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:191.35pt; text-indent:-63.8pt;} @list l0:level8 {mso-level-text:"%1/.%2/.%3/.%4/.%5/.%6/.%7/.%8"; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:219.7pt; text-indent:-70.9pt;} @list l0:level9 {mso-level-text:"%1/.%2/.%3/.%4/.%5/.%6/.%7/.%8/.%9"; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:255.1pt; text-indent:-85.0pt;} ol {margin-bottom:0cm;} ul {margin-bottom:0cm;} -->

1       发送 QNX 消息

Photon 应用可以使用 MsgSend() 传递消息,但接收方必须迅速 MsgReply() ,这是因为 Photon 事件在应用阻塞时不处理。 ( 当应用中包含多个线程处理事件时宾切你在调用 MsgSend() 之前调用 PtLeave() 并在之后调用 PtEnter() 。对于多线程编程,请参照 Parallel Operations chapter 这一章。

以下例子演示了从一个 text widget 获取字符串并且发送到另一进程,得到回复后显示在同一 text widget :

 

 

 

 

<!-- /* Font Definitions */ @font-face {font-family:Wingdings; panose-1:5 0 0 0 0 0 0 0 0 0; mso-font-charset:2; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:0 268435456 0 0 -2147483648 0;} @font-face {font-family:宋体; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:SimSun; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:1; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:0 0 0 0 0 0;} @font-face {font-family:Cambria; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:0; mso-generic-font-family:roman; mso-font-pitch:variable; mso-font-signature:-1610611985 1073741899 0 0 159 0;} @font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:-1610611985 1073750139 0 0 159 0;} @font-face {font-family:"/@宋体"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-unhide:no; mso-style-qformat:yes; mso-style-parent:""; margin:0cm; margin-bottom:.0001pt; text-align:justify; text-justify:inter-ideograph; text-indent:10.0pt; mso-char-indent-count:2.0; line-height:150%; mso-pagination:none; font-size:12.0pt; mso-bidi-font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:宋体; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi; mso-font-kerning:1.0pt;} h1 {mso-style-priority:9; mso-style-unhide:no; mso-style-qformat:yes; mso-style-link:"标题 1 Char"; mso-style-next:正文; margin-top:17.0pt; margin-right:0cm; margin-bottom:16.5pt; margin-left:0cm; text-align:justify; text-justify:inter-ideograph; text-indent:10.0pt; mso-char-indent-count:2.0; line-height:240%; mso-pagination:lines-together; page-break-after:avoid; mso-outline-level:1; font-size:22.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-font-kerning:22.0pt;} h2 {mso-style-priority:9; mso-style-qformat:yes; mso-style-link:"标题 2 Char"; mso-style-next:正文; margin-top:13.0pt; margin-right:0cm; margin-bottom:13.0pt; margin-left:0cm; text-align:justify; text-justify:inter-ideograph; text-indent:10.0pt; mso-char-indent-count:2.0; line-height:173%; mso-pagination:lines-together; page-break-after:avoid; mso-outline-level:2; font-size:16.0pt; font-family:"Cambria","serif"; mso-ascii-font-family:Cambria; mso-ascii-theme-font:major-latin; mso-fareast-font-family:宋体; mso-fareast-theme-font:major-fareast; mso-hansi-font-family:Cambria; mso-hansi-theme-font:major-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:major-bidi; mso-font-kerning:1.0pt;} h3 {mso-style-priority:9; mso-style-qformat:yes; mso-style-link:"标题 3 Char"; mso-style-next:正文; margin-top:13.0pt; margin-right:0cm; margin-bottom:13.0pt; margin-left:0cm; text-align:justify; text-justify:inter-ideograph; text-indent:10.0pt; mso-char-indent-count:2.0; line-height:173%; mso-pagination:lines-together; page-break-after:avoid; mso-outline-level:3; font-size:16.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-font-kerning:1.0pt;} p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph {mso-style-priority:34; mso-style-unhide:no; mso-style-qformat:yes; margin:0cm; margin-bottom:.0001pt; text-align:justify; text-justify:inter-ideograph; text-indent:21.0pt; mso-char-indent-count:2.0; line-height:150%; mso-pagination:none; font-size:12.0pt; mso-bidi-font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:宋体; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi; mso-font-kerning:1.0pt;} span.1Char {mso-style-name:"标题 1 Char"; mso-style-priority:9; mso-style-unhide:no; mso-style-locked:yes; mso-style-link:"标题 1"; mso-ansi-font-size:22.0pt; mso-bidi-font-size:22.0pt; mso-font-kerning:22.0pt; font-weight:bold;} span.2Char {mso-style-name:"标题 2 Char"; mso-style-priority:9; mso-style-unhide:no; mso-style-locked:yes; mso-style-link:"标题 2"; mso-ansi-font-size:16.0pt; mso-bidi-font-size:16.0pt; font-family:"Cambria","serif"; mso-ascii-font-family:Cambria; mso-ascii-theme-font:major-latin; mso-fareast-font-family:宋体; mso-fareast-theme-font:major-fareast; mso-hansi-font-family:Cambria; mso-hansi-theme-font:major-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:major-bidi; font-weight:bold;} span.3Char {mso-style-name:"标题 3 Char"; mso-style-priority:9; mso-style-unhide:no; mso-style-locked:yes; mso-style-link:"标题 3"; mso-ansi-font-size:16.0pt; mso-bidi-font-size:16.0pt; font-weight:bold;} .MsoChpDefault {mso-style-type:export-only; mso-default-props:yes; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi;} /* Page Definitions */ @page {mso-page-border-surround-header:no; mso-page-border-surround-footer:no;} @page Section1 {size:612.0pt 792.0pt; margin:72.0pt 90.0pt 72.0pt 90.0pt; mso-header-margin:36.0pt; mso-footer-margin:36.0pt; mso-paper-source:0;} div.Section1 {page:Section1;} /* List Definitions */ @list l0 {mso-list-id:904681410; mso-list-type:hybrid; mso-list-template-ids:-638408684 67698689 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;} @list l0:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:45.0pt; text-indent:-21.0pt; font-family:Wingdings;} @list l1 {mso-list-id:1010639450; mso-list-template-ids:67698717;} @list l1:level1 {mso-level-text:%1; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:21.25pt; text-indent:-21.25pt;} @list l1:level2 {mso-level-text:"%1/.%2"; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:49.6pt; text-indent:-1.0cm;} @list l1:level3 {mso-level-text:"%1/.%2/.%3"; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:70.9pt; text-indent:-1.0cm;} @list l1:level4 {mso-level-text:"%1/.%2/.%3/.%4"; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:99.2pt; text-indent:-35.4pt;} @list l1:level5 {mso-level-text:"%1/.%2/.%3/.%4/.%5"; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:127.55pt; text-indent:-42.5pt;} @list l1:level6 {mso-level-text:"%1/.%2/.%3/.%4/.%5/.%6"; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:163.0pt; text-indent:-2.0cm;} @list l1:level7 {mso-level-text:"%1/.%2/.%3/.%4/.%5/.%6/.%7"; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:191.35pt; text-indent:-63.8pt;} @list l1:level8 {mso-level-text:"%1/.%2/.%3/.%4/.%5/.%6/.%7/.%8"; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:219.7pt; text-indent:-70.9pt;} @list l1:level9 {mso-level-text:"%1/.%2/.%3/.%4/.%5/.%6/.%7/.%8/.%9"; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:255.1pt; text-indent:-85.0pt;} @list l2 {mso-list-id:1058938109; mso-list-type:hybrid; mso-list-template-ids:1973029100 67698689 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;} @list l2:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:45.0pt; text-indent:-21.0pt; font-family:Wingdings;} @list l3 {mso-list-id:1983578164; mso-list-type:hybrid; mso-list-template-ids:-527251092 67698689 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;} @list l3:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:45.0pt; text-indent:-21.0pt; font-family:Wingdings;} ol {margin-bottom:0cm;} ul {margin-bottom:0cm;} -->

1       接收 QNX 消息

为了在 Photo 应用中处理非 Photon 消息,你必须要注册一个 input handling procedure( 输入处理函数,或 input handler) ,否则事件将不被处理。这是因为 Photon 事件处理循环中的 MsgReceive() 忽略了非 Photon 事件。

注意 :你可以创建自己的消息循环并在其中调用 MsgReceive() ,但请记住应用及其接口会一直阻塞直到某个进程发送消息。因此,使用前面讨论的 input handler 显然更好。

一个 input handler 负责对接收自另一应用程序的消息进行处理。当你将 input handler 注册到 widget 库时,你指定了 input handler 相关联的 pid 。

你可以在应用程序中对于一个 pid 定义多于一个 input handler 。当自进程接收到消息时, widget 库将从 input handler 列表中开始处理,并遵从“后定义先执行”的方式,直到一个 input handler 处理了该消息 ( 也就是,该处理不返回 Pt_CONTINUE) 。可以查看 Pt_CONTINUE 定义。

你可以通过指定 pid 为 0 来注册一个非特定的 input handler ,这个 input handler 在应用接收到以下消息时调用:

l  任意不含发送者 pid 的输入处理的非 Photon 消息。

l  任意包含发送者 pid 的输入处理的非 Photon 消息,该消息未被处理,即,前一输入处理返回 PT_CONTINUE 。

l  一个用户脉冲。 ( 例如,一个非负数的脉冲 )

1.1     Adding an input handler

在应用程序初始化的时候调用 PtAppAddInput() 来注册 input handler 。语法如下,更多信息参见 Photon Library Reference :

PtInputId_t *PtAppAddInput(

                 PtAppContext_t app_context,

                 pid_t pid,

                 PtInputCallbackProc_t input_func,

                 void *data );

参数列表:

app_context

应用程序上下文地址,使用一个 PtAppContext_t 结构来管理应用相关联的数据,如果使用 NULL 作为参数,将使用默认上下文。

pid

将要处理该消息的进程 ID ,如果使用 0 作为参数,将会发送消息到所有进程。

input_func

PtInputCallbackProc_t 类型的处理函数,更多描述参见 Photon Library Reference 。

data

额外数据,用来传递参数。

PtAppAddInput() 返回一个 input handler ID 的指针,可以用来删除该输入处理。

input handler 的原型如下:

int input_proc( void *data,

                int rcvid,

                void *msg,

                size_t msglen );

参数意义:

data

你传递到该输入处理的额外数据的指针。

rcvid

消息发送时设置的接收进程 id 。

msg

发送的消息指针。

msglen

消息缓冲区大小,如果真实的消息大小超过缓冲区大小,可以使用 MsgRead() 读取剩余消息内容。

你也可以定义 input handler 类型为 PtInputCallbackProcF_t 来使用编译器的类型检查特性。

注意 :如果 input handler 修改了显示,请确保调用了 PtFlush() 来刷新。

一个 input handler 必须返回以下几个值中的一个:

Pt_CONTINUE

input handler 不能识别此消息。如果还有其他 input handler 关联到相同的进程 ID ,将会调用这些处理函数,如果没有,或者所有关联该进程 ID 的消息处理都返回 Pt_CONTINUE ,将会被转入 rcvid 为 0 的输入处理。如果所有 input handler 返回 Pt_CONTINUE ,该消息返回值被设置为 ENOSYS 。

Pt_END

该消息被识别、处理并且从 input handler 列表中删除,别的 input handler 不会被调用。

Pt_HALT

消息被识别、处理但不从列表删除,将交由另外的 input handler 函数处理。

1.1.1     name_attach() and PtAppAddInput()

如果可能,一般情况下你应该使用 connection 而非 name_attach() 来建立一个进程间连接。然而,以下情况你无法使用 Photon connection :

l  连接的 client 端不是一个 Photon 应用。

l  连接的进程属于不同的 Photon session 。即使你在运行多个不同的 Photon 任务于一台计算机,或者你的 Photon 任务由多个运行于不同计算机的应用组成,并且正好两个相互通信的进程位于不同计算机。

PtAppAddInput() 和 name_attach() 都尽力创建一个 _NTO_CHF_COID_DISCONNECT 和 _NTO_CHF_DISCONNECT 集合的通道 ( 参见 QNX Neutrino Library Reference) 。如果你的应用程序调用了这两个函数,你需要让 Photon 使用与 name_attach() 相同的通道,该通道可以使用 PhChannelAttach() 获得,具体用法如下:

PhChannelAttach( chid, -1, NULL );

该调用必须在 name_attach() 和 PtAppAddInput() 之前。

如果你想为 Photon 创建分离的 channel ,只要你创建并传递给 PhChannelAttach() 调用之前或在 name_attach() 调用之后,这都不是问题。但请记住,由于某些 Photon library 中的方法认为 Photon channel 拥有两个 DISCONNECT 标识,将可能不能正常工作。其中的一种情况是检测中止连接方法 ( 参见 PtConnectionClientSetError() and PtConnectionServerSetError()) 及其任何依赖项。

1.2     Removing an input handler

可以通过以下手段删除消息处理 input handler :

l  返回 Pt_END 。

或者

l  调用 PtAppRemoveInput() 并且传递 PtAppAddInput() 返回的 ID 值。

1.3     Message buffer size

正如以上讨论的,在输入函数中包含以下参数:

msg

指向一个接收消息的缓冲区的指针。

msglen

缓冲区大小。

缓冲区可能不够保存完整消息内容,一个解决方法是使用前几个字节来标识消息类型来判断消息内容的大小,当你知道消息大小后,就可以:

l  使用 MsgReadv() 获取完整消息内容。

或者

l  拷贝你获取到的缓冲区部分到一个新的缓冲区,之后调用 MsgReadv() 获取剩余部分。添加剩余部分到前面以接收到的部分组成完整内容。

作为选择,你可以设置事件处理缓冲区为应用程序可能接收消息内容的最大值 ( 如果预先可知的话 ) ,这可以通过调用 PtResizeEventMsg() 来实现,当然你必须在接收到任何消息之前设定这个值。

注意 : PtResizeEventMsg() 不会将缓冲区大小设置少于某个系统定义的最低值。

1.4     Example — logging error messages

以下代码展示对于非特定消息的应用:用来做任意进程的错误记录。当接收到消息时,应用程序将消息内容显示于 multiline text widget 中。 ( 示例中的 log_message 在别处定义 )

 

 

 

 

<!-- /* Font Definitions */ @font-face {font-family:宋体; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:SimSun; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:1; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:0 0 0 0 0 0;} @font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:-1610611985 1073750139 0 0 159 0;} @font-face {font-family:"/@宋体"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-unhide:no; mso-style-qformat:yes; mso-style-parent:""; margin:0cm; margin-bottom:.0001pt; text-align:justify; text-justify:inter-ideograph; text-indent:10.0pt; mso-char-indent-count:2.0; line-height:150%; mso-pagination:none; font-size:12.0pt; mso-bidi-font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:宋体; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi; mso-font-kerning:1.0pt;} .MsoChpDefault {mso-style-type:export-only; mso-default-props:yes; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi;} /* Page Definitions */ @page {mso-page-border-surround-header:no; mso-page-border-surround-footer:no;} @page Section1 {size:612.0pt 792.0pt; margin:72.0pt 90.0pt 72.0pt 90.0pt; mso-header-margin:36.0pt; mso-footer-margin:36.0pt; mso-paper-source:0;} div.Section1 {page:Section1;} -->

应用注册了一个 input_proc() 函数来处理其他进程传递的非 Photon 消息。

 

input_proc() 函数首先检查传入消息类型。如果消息类型不能识别,则 input handler 函数立即返回,这样就能交由别的 input handler 正常处理该消息。

如果消息类型是一个 log 消息,函数首先确保 Photon 读取了缓冲区中的所有内容 ( 可以通过查看 msglen 参数判断 ) ,然后 input_proc() 函数调用 add_msg() 来添加 text widget 的消息处理来对该消息处理。

当消息处理完成时,返回 Pt_HALT ,这样确保消息不从队列中删除。

深入解析进程间通信:从IPC原理到工业应用实战 进程间通信是操作系统与分布式系统的核心基础,它定义了不同进程间交换数据与协调工作的机制。其原理在于通过共享内存、消息传递或信号等内核提供的原语,绕过低效的网络协议栈,实现本地进程间的直接数据交换。这项技术的核心价值在于为高性能计算、实时系统及模块化应用提供了无可替代的低延迟、高吞吐量通信能力,尤其适用于图形渲染、数据库缓存、工业控制等对性能与确定性要求极高的场景。本文聚焦于IPC 7077等工业协议及共享内存等关键技术,通过分析典型错误如ipc connection error,系统阐述在Linux/Uni 阅读详情

相关推荐

Grok车机版为何无法控制特斯拉?揭秘云端大模型与车载系统的隔离机制

大语言模型(LLM)作为当前AI应用的核心技术,其在智能汽车场景中的落地面临架构、安全与工程三重挑战。云端大模型依赖高带宽低延迟网络,而车载系统要求毫秒级响应与车规级功能安全(ISO 26262),二者在实时性、确定性与数据通路层面存在天然鸿沟。Grok作为典型通用LLM,受限于算力部署位置、操作系统沙箱权限及隐私合规约束,无法访问CAN总线、车辆状态或执行控制指令,本质是‘能力在线、交互离线’。该现象折射出AI产品化关键:模型能力不等于系统智能,真正价值在于垂直场景下的数据闭环与安全可控。本文以Grok与

weixin_34115824的博客 920

QNX-IPC通信

在QNX中,消息可以分为同步消息和异步消息,同步消息需要消息接收者和发送者,异步消息类似于一种通知机制,QNX主要使用的是IPC进行通信,下面是QNX中支持的IPC通信: QNX内核特有的有IPC通信有:在QNX中的Message-passing通信是主从式,双向通信的,在每一个进程中都有一个线程来负责通信,当为收到回信时,线程会block住,直到收到回复信息简单来说如果一个线程(客户端线程)执行了MsgSend()向另一个线程(服务器线程)发送消息,发送消息的线程就会阻塞,直到另一个线程执行了MsgRec

weixin_43824344的博客 2242

qnx进程通信

qnx进程通信

wangbuji的博客 2021

QNX_IPC

QNX IPC 进程间通信在将微内核从嵌入式实时内核转换为完整的POSIX操作系统的过程中起着至关重要的作用。 随着各种提供服务的进程被添加到微内核中,IPC是将这些组件连接成一个内聚整体的粘合剂。虽然在QNX中微子RTOS中,消息传递是IPC的主要形式,但是也有其他几种形式。 除非另有说明,否则这些其他形式的IPC是建立在我们的native消息传递之上的。该策略是创建一个简单、健壮的IPC服务,...

wwq_wu_hxd的专栏 2259

【信息科学与工程学】【通信工程】第一百九十一篇 路由器体系结构03

编号类型领域问题详细的数学分析(逐步推理)参数列表(表达式 / 数值范围 / 边界 / 测量)关联知识839DCI演进 · 收敛DCI 2030 年三大技术收敛方向步骤1:方向一:IPoDWDM 成为绝对主流(Omdia 2027 59% → 2030 80%+),OTN 退化为 OLS 纯光层。步骤2:方向二:800ZR+ 取代 400ZR 成为主力速率,PCS 使 800G 达 600–1000km。步骤3:方向三:AI 集群 DCI 催生 1.6T/3.2T 超短距(<10km)相干模块(OSFP-X

weixin_49199313的博客 856

TVS 和压敏电阻联合使用进行浪涌保护时,压敏电阻的压敏电压要低于TVS 的钳位电压 VC。

通过先让MOV接管,可以确保在大多数情况下,电压不会迅速上升到TVS二极管的钳位电压,从而保护TVS二极管免受持续高能量冲击的损害。总结来说,将MOV的压敏电压设置得低于TVS二极管的钳位电压,可以提供一种分级的保护机制,优化浪涌保护性能,同时保护敏感的TVS二极管不被过度的能量冲击损坏,并延长其使用寿命。MOV吸收的能量(Wmov):假设浪涌电流为10kA,MOV导通后将电压限制在300V,那么Wmov = Ipp * Vmov = 10kA * 300V = 3MW。例如,Vmov可以设定为275V。

weixin_66642980的博客 2244

QNX IPC机制

文章目录QNX微内核介绍Synchronous message passingMessage copyingChannels and connectionsPulses优先级继承与消息Message-passing APIRobust implementations with Send/Receive/ReplyEventsSignalsPOSIX message queuesShared Mem...

weixin_44280688的博客 4052

Mamba再封神!与YOLO结合,拿下二区!好发不卷!

相比传统的YOLO改进,Mamba是新技术,两者结合尚在蓝海阶段,可发挥空间大!更为关键的是,它在检测精度和速度方面,都让以往的YOLO模型难以望其项背!比如代表模型Mamba YOLO,便在参数减少45.5%、FLOPs减少50%的同时,精度还比YOLOv8高6.1%!这主要得益于,Mamba能够捕捉长期依赖关系,而YOLO则擅长捕捉局部特征,两者能够优势互补,且Mamba线性复杂度的特性,也有利于提高计算效率!为了让大家能够紧跟前沿发展,找到更多灵感启发,我给大家10种。

2401_88190197的博客 2506

[转]QNX_IPC机制-进程线程与kernel通信机制

如果你认为本系列文章对你有所帮助,请大家有钱的捧个钱场,点击此处赞助,赞助额0.1元起步,多少随意 声明:本文只用于个人学习交流,若不慎造成侵权,请及时联系我,立即予以改正 锋影 email:174176320@qq.com 介绍 Interprocess Communication(IPC,进程间通信)在QNX Neutrino从一个嵌入式实时系统向一个全面的POSIX系统转变起...

xjhhjx的专栏 1028

Maya绑定:人物绑定详细案例(创建骨骼、镜像骨骼、IK创建、IK打组、IK控制器、FK控制器、烘焙动画、导出)

Maya绑定:人物绑定详细案例(创建骨骼、镜像骨骼、IK创建、IK打组、IK控制器、FK控制器、烘焙动画、导出)

m0_45877477的博客 1627

Cadence SIP Layout 简单教程-第二章

[从whp1920 网易博客迁移至优快云] 第一章在正式布线之前做了必须做的准备工作,下面进入正题,打开Candence SIP RF Layout GXL软件。 第一节 导入外形尺寸 打开SIP设置文件保存路径,如下图所示进入导入DXF页面,选中前一章时画好的外框图。打开导入界面后,再进入DXF In Edit/View Layers界面选择所有层,导入Class选择DRAWING FOR...

whp1920的博客 6939

qnx系统学习

qnx操作系统

wangbuji的博客 7238

新手必看:C#调用YOLO模型完成图片/视频目标检测(上位机版)

新手学习C#调用YOLO模型,核心是先把基础流程跑通,再逐步优化。图片检测是基础,视频检测就是在图片的基础上加循环和线程,而上位机的实际项目,就是在这个基础上适配工业硬件和业务需求。本文的代码都是新手能直接复制运行的,如果你运行时遇到问题,先检查前期准备是否到位,再看避坑指南。记住,新手别追求一步到位,先实现功能,再慢慢优化性能和界面。等你能熟练调用YOLO模型后,再去研究模型训练、量化优化等进阶内容,会轻松很多。

这里只有干货:从 Modbus 通信到 MES 对接,从 YOLO 训练到工控机部署,带你搞定工业软件开发全流程。 984

QNX system architecture 3 - Interprocess Communication (IPC)

从微内核构建全面的POSIX操作系统,进程间通信起到至关重要的作用。当各种提供服务的进程加到微内核中,IPC做为粘合层,把这些部件连结成一个紧密的整体。 尽管消息传递是QNX Neutrino RTOS IPC的主要形式,还有其他集中形式的IPC,除非提到,这些其他形式的IPC都是构建在本地消息传递基础之上。策略是在内核中创建一个简单的,鲁棒,易扩展的的IPC服务。更多复杂的IPC服务可以在

zjy900507的博客 715

SAP 系统间信任关系配置全攻略:从 SM59 到 SMT1 的实践与风险控制

本文介绍了在SAP系统间配置信任关系的详细流程与最佳实践。文章以SAP Gateway与后端系统架构为场景,从SM59创建RFC目的地开始,到SMT1建立信任关系,再到授权对象S_RFCACL的配置,提供了完整的操作指南。重点包括:使用标准命名规范创建专用RFC连接、通过向导完成系统间信任登记、严格控制S_RFCACL授权范围等。文中还分享了真实项目案例、可复用的检查清单以及常见问题的排查思路,帮助用户实现稳定可靠的跨系统无密码调用,同时确保安全性。

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 321

【Go语言实战】(2) Gin+Vue 电子商城

618来!!不用纠结去哪里剁手了!直接自己安排一个商场不香吗??

面向生活编程 4827

浅谈QNX进程间通信(IPC)(转)

在QNX Neutrino中消息传递(Message passing)是IPC的主要形式,其他的姓氏也是基于消息传递实现的。QNX中提供的IPC形式如何下图所示:一、Synchronous message passing 同步消息传递如果一个线程执行了MegSend()方法向另一个线程(可以是不同的进程)发送消息,它会被阻塞,知道目标线程执行了MsgReceive(),并处理消息,...

xiaxi的专栏 1426

Python爬虫实战:京东/淘宝商品价格与评论监控系统——从User-Agent伪装到编码陷阱的全面攻克

在电商数据驱动决策的今天,无论是个人消费者想抓住历史低价,还是市场分析师需要追踪竞品动态,抑或是算法交易员依赖实时价格信号,自动化的商品价格与评论监控系统都已成为不可或缺的工具。然而,电商平台的反爬虫策略日益严苛,字符编码的“暗坑”更是让初学者屡屡碰壁。本文将以京东(JD.com和淘宝(Taobao.com两大主流平台为目标,手把手带你构建一个稳定、高效的商品监控爬虫。User-Agent伪装——如何模拟真实浏览器行为,突破初级反爬。GBK/UTF-8编码混战。

2201_76125261的博客 75

QNX IPC介绍(一)

IPC(inter-Process Communication)是进程通讯的缩写,一linu中般有如下的实现方式管道Signal消息队列信号量共享内存套接字(Socket)而QNX的IPC和Linux稍微有些不同,QNX可以支持以下几种IPC通讯:Messgae-passing(消息传递)Pules(QNX脉冲)Signals(QNX消息)Event delivery(QNX事件)消息队列共享内存管道套接字(Socket)

Benjenson的博客 1389

VC中sqlite的使用

在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

QNX中进程间通信(IPC)之Signal篇

主要内容翻译自QNX开发文档,根据自己理解翻译,错误之处在所难免,目的还是提供给大家对照阅读,我自己也写了一些代码,抽空后继也会放上   Normal 0 7.8 磅 0 2 false false false EN-US ZH-CN X-

「行到水穷处,坐看云起时」 2497

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

QNX----知识 频道(Channel)与连接(Connect)

QNX频道的概念 :  频道(Channel)与连接(Connect)  消息传递是基于服务器与客户端的模式来进行的,那么客户端怎样才能与服务器端通讯呢?最简单的,当然是指定对方的进程号。要发送的一方,将消息加一个头,告诉内核“把这个消息发给pid 12345”就行了。其实这也是QNX4时候的做法。但QNX6开始完整支持POSIX线程后,这种方法似乎就不太适合了。如果服务器,有两个线程,分别进...

u011996698的博客 2524

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

QNX驱动开发——操作系统之进程调度和进程通信

一、进程调度方法 1.FIFO:先进先出队列法。一个最高优先级的线程可以一直执行到结束或是主动放弃CPU。高优先级的线程可以随时中断低优先级的线程,获得CPU的使用权限,与之相同优先级的CPU也只能等待其交出CPU的使用权限后才能按排队的顺序先后执行。 2.Round Robin:循环法。除了对于最高的相同优先级的使用时间片轮转的方法外,其他特点与FIFO法相同。注意此处的时间片轮转与wind

DanielLee_ustb的专栏 3745

2-2-18-3 QNX 进程间通信(IPC)(一)

进程间通信在微内核从嵌入式实时内核到全面POSIX操作系统的转换中起到了重要作用。随着各种提供服务的进程被添加到微内核中,IPC是把这些组件连接成一个内聚整体的“粘合剂”。消息传递是QNX 操作系统中 IPC 的主要形式,本文从消息传递的过程、简单消息传递,以及消息传递时如何进行消息拷贝等方向进行了概述,同时还介绍了其他进程间通信的方式或形式,可以让读者对QNX系统中的通信及同步服务有个清晰了解。

星原飞火的博客 1973

QNX中进程间通信(IPC)之Pulse篇

主要内容翻译自QNX开发文档,根据自己理解翻译,错误之处在所难免,目的还是提供给大家对照阅读,我自己也写了一些代码,抽空后继也会放上  Normal 0 7.8 磅 0 2 false false false EN-US ZH-CN X-NONE

「行到水穷处,坐看云起时」 4297

漫谈QNX(架构/进程,线程,同步,进程间通信IPC)

架构 说起Blackberry的QNX操作系统, 想必大家都听说过,但到底为什么QNX能如此有名?难道微软的Windows和Linux都不能与之抗衡? 美国NASA的太空接驳飞船也使用QNX操作系统 QNX采用微内核结构,也就是说,内核非常非常非常小。这样一方面启动速度非常快,另一方面安全性稳定性大大提高。 QNX构架是有一个微型内核,然后又包含许多相关进程。这样的好处是,即使有一个进程出错,也不会影响内核。 各个服务进程以及应用进程之间通过内部进程通信IPC的方式进行沟通,如下图: Q

usstmiracle的博客 1万+

QNX----第3章 进程间通信(1部分)

QNX----第3章 进程间通信(1部分) 进程间通信在将微内核从嵌入式实时内核转换为全面的POSIX操作系统的过程中起着至关重要的作用。随着各种服务提供进程被添加到微内核中,IPC是将这些组件连接到一个内聚整体的粘合剂。 虽然消息传递是QNX中微子RTOS中IPC的主要形式,但也有其他几种形式。除非另有说明,那些其他形式的IPC是在我们的本机消息传递之上构建的。策略是创建一个简单、健壮的IP...

u011996698的博客 3927
上一篇: QNX下显示图片
下一篇: QNX中进程间通信(IPC)之Pulse篇
Soloman
博客等级 码龄25年 171粉丝 159原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值