日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

qnx pps

發布時間:2025/3/21 编程问答 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 qnx pps 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1、什么是pps

pps:Persistent Publish/Subscribe?

With?PPS, publishing is asynchronous: the subscriber need not be waiting for the publisher.

對于發布者來說是異步的,訂閱者也不需要等待發布者

In fact, the publisher and subscriber rarely know each other; their only connection is an object that has a meaning and purpose for both publisher and subscriber.

?

2、為什么需要pps

在默認狀態下,QNX PPS服務是作為推送式發布系統運行的;也就是說,發布者會將數據推送到對象中,訂閱者會根據通知或在閑暇時讀取數據。(手機app更新消息就是這樣)

但有些數據(如接口上的數據包計數)變化太快,因此無法通過使用默認推送發布的PPS有效地進行發布。為此,QNX PPS還提供了一種選項,允許訂閱者將PPS變成提取式發布系統。當訂閱者打開具有該選項的對象并發出一個read()調用時,該對象的所有發布者會收到一個通知以在對象中寫入當前數據。訂閱者的讀取會一直阻塞直至對象的數據得到更新并返回新的數據。利用這種提取機制,PPS訂閱者能按其需要的速度向發布者檢索數據,從而實現了真正意義上的按需發布。

3、pps 的功能作用

4、qnx 中如何使用pps

http://www.qnx.com/developers/docs/7.1/index.html#com.qnx.doc.pps.developer/topic/examples.html???????q???????http://www.qnx.com/developers/docs/7.1/index.html#com.qnx.doc.pps.developer/topic/examples.html

qnx 使用案例:

One publisher:

#include <stdlib.h> #include <stdio.h> #include <unistd.h> #include <fcntl.h> #include <string.h>int main(int argc, char *argv[]) {int fd;int state = 0;char buf[256];struct stat stat_buf;int count = 0;ssize_t len, bytes_written;/* Is PPS running? */if (stat( "/pps", &stat_buf) != 0){if (errno == ENOENT)printf ("The PPS server isn't running.\n");elseperror ("stat (/pps)");return EXIT_FAILURE;}/* Create the "button" object (if it doesn't already exist). */fd = open( "/pps/example/button", O_RDWR | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO );if ( fd < 0 ){perror ("Couldn't open /pps/example/button");return EXIT_FAILURE;}/* Loop forever, toggling the state of the button. */while ( 1 ){usleep (500);count++;len = snprintf(buf, 256, "state::%s\npub1::%d", state ? "on" : "off", count);bytes_written = write( fd, buf, len );if (bytes_written == -1){perror ("write()");}else if (bytes_written != len){printf ("Bytes written: %d String length: %d\n", bytes_written, len);}if ( state == 0 )state = 1;elsestate = 0;}return EXIT_SUCCESS; }

One Subscribers:

#include <stdlib.h> #include <stdio.h> #include <unistd.h> #include <fcntl.h> #include <string.h>int main(int argc, char *argv[]) {int fd;char buf[256];int num_bytes;fd = open( "/pps/example/button?wait,delta", O_RDONLY );if ( fd < 0 ){perror ("Couldn't open /pps/example/button");return EXIT_FAILURE;}/* Loop, echoing the attributes of the button. */while (1){num_bytes = read( fd, buf, sizeof(buf) );if (num_bytes > 0){write (STDOUT_FILENO, buf, num_bytes);}}return EXIT_SUCCESS; }

?

總結

以上是生活随笔為你收集整理的qnx pps的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。