ArceOS系统调用 - FastDDS移植

什么是FastDDS

eProsima Fast DDSDDS(数据分发服务)规范的 C++ 实现 ,该规范是由对象管理组 (OMG)定义的协议。eProsima Fast DDS库提供了应用程序编程接口 (API) 和通信协议,用于部署以数据为中心的发布者-订阅者 (DCPS) 模型,目的是在实时系统之间建立高效可靠的信息分发。eProsima Fast DDS在资源处理方面具有可预测、可扩展、灵活和高效的特点。为了满足这些要求,它利用类型化接口并依赖于多对多分布式网络范例,从而巧妙地分离了通信的发布者和订阅者端 。eProsima Fast DDS包括:

  1. DDS API实现。
  2. Fast DDS-Gen,一种用于连接类型接口和中间件实现的生成工具。
  3. 底层RTPS有线协议实现。

鉴于以上所有情况,eProsima Fast DDS已被选为 机器人操作系统 2 (ROS 2)在每个长期 (LTS) 版本和大多数非 LTS 版本中支持的默认中间件。

分析FastDDS的在Linux中的系统调用

# 发布者
./DDSHelloWorldExample publisher
Starting 
Publisher running 10 samples.
Publisher matched.
Message: HelloWorld with index: 1 SENT
Message: HelloWorld with index: 2 SENT
Message: HelloWorld with index: 3 SENT
Message: HelloWorld with index: 4 SENT
Message: HelloWorld with index: 5 SENT
Message: HelloWorld with index: 6 SENT
Message: HelloWorld with index: 7 SENT
Message: HelloWorld with index: 8 SENT
Message: HelloWorld with index: 9 SENT
Message: HelloWorld with index: 10 SENT
% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
 68.00    0.008722         396        22           futex
 13.44    0.001724         123        14           sendto
  3.91    0.000502          41        12           munmap
  2.54    0.000326          40         8           clone3
  1.96    0.000251          13        19         8 setsockopt
  1.93    0.000247           3        63           mmap
  1.58    0.000203           5        39           close
  1.43    0.000183           7        23           mprotect
  0.76    0.000097           1        79        55 openat
  0.54    0.000069          69         1           clock_nanosleep
  0.51    0.000066           4        14           socket
  0.38    0.000049           6         8         1 unlink
  0.37    0.000048          16         3         3 shutdown
  0.32    0.000041           2        15           brk
  0.30    0.000038           4         9           epoll_ctl
  0.27    0.000035           2        17           rt_sigprocmask
  0.23    0.000030           0        33        10 newfstatat
  0.20    0.000026           2         9           bind
  0.20    0.000026           2        10           flock
  0.20    0.000026           8         3           fallocate
  0.19    0.000024           6         4           write
  0.13    0.000017           0        18           recvmsg
  0.06    0.000008           0        16           read
  0.06    0.000008           1         6           getsockname
  0.06    0.000008           8         1           link
  0.06    0.000008           8         1           eventfd2
  0.05    0.000006           1         5           ioctl
  0.05    0.000006           3         2           getsockopt
  0.04    0.000005           2         2           getrandom
  0.03    0.000004           1         3           fchmod
  0.03    0.000004           4         1           set_tid_address
  0.03    0.000004           4         1           timerfd_create
  0.03    0.000004           4         1           epoll_create1
  0.02    0.000003           1         2         1 arch_prctl
  0.02    0.000003           3         1           set_robust_list
  0.02    0.000003           3         1           rseq
  0.02    0.000002           0         5           getpid
  0.01    0.000001           0         2           lseek
  0.00    0.000000           0         1           rt_sigaction
  0.00    0.000000           0         4           pread64
  0.00    0.000000           0         1         1 access
  0.00    0.000000           0         2         2 connect
  0.00    0.000000           0         1           execve
  0.00    0.000000           0         1           uname
  0.00    0.000000           0         1           geteuid
  0.00    0.000000           0         1           prlimit64
------ ----------- ----------- --------- --------- ----------------
100.00    0.012827          26       485        81 total
# 订阅者
/DDSHelloWorldExample subscriber
Starting 
Subscriber running. Please press enter to stop the Subscriber
Subscriber matched.
Message HelloWorld 1 RECEIVED
Message HelloWorld 2 RECEIVED
Message HelloWorld 3 RECEIVED
Message HelloWorld 4 RECEIVED
Message HelloWorld 5 RECEIVED
Message HelloWorld 6 RECEIVED
Message HelloWorld 7 RECEIVED
Message HelloWorld 8 RECEIVED
Message HelloWorld 9 RECEIVED
Message HelloWorld 10 RECEIVED
Subscriber unmatched.
^Cstrace: Process 157950 detached
% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
 17.85    0.002071          26        79        55 openat
 10.09    0.001171          18        62           mmap
  7.91    0.000918          65        14         3 setsockopt
  6.89    0.000800          28        28           futex
  6.46    0.000750          22        34        10 newfstatat
  6.32    0.000733          81         9           sendto
  5.66    0.000657          43        15           rt_sigprocmask
  4.33    0.000502          22        22           mprotect
  4.05    0.000470          16        28           close
  3.83    0.000445          24        18           recvmsg
  3.58    0.000415          59         7           clone3
  3.12    0.000362          25        14           socket
  2.22    0.000258          16        16           read
  2.12    0.000246          15        16           brk
  2.05    0.000238          79         3           fallocate
  1.67    0.000194          21         9           epoll_ctl
  1.39    0.000161          17         9           bind
  1.22    0.000142          17         8           flock
  1.12    0.000130          26         5         1 unlink
  1.10    0.000128          32         4           write
  0.90    0.000105          17         6           getsockname
  0.83    0.000096          32         3           fchmod
  0.73    0.000085          21         4           pread64
  0.67    0.000078          15         5           ioctl
  0.65    0.000076          15         5           getpid
  0.50    0.000058          19         3           munmap
  0.33    0.000038          19         2           getsockopt
  0.32    0.000037          18         2         2 connect
  0.29    0.000034          34         1         1 access
  0.28    0.000033          16         2           lseek
  0.26    0.000030          15         2         1 arch_prctl
  0.22    0.000026          26         1           link
  0.20    0.000023          23         1           timerfd_create
  0.18    0.000021          21         1           eventfd2
  0.17    0.000020          20         1           epoll_create1
  0.16    0.000018          18         1           rt_sigaction
  0.14    0.000016           8         2           getrandom
  0.09    0.000010          10         1           uname
  0.09    0.000010          10         1           geteuid
  0.00    0.000000           0         1           execve
  0.00    0.000000           0         1           set_tid_address
  0.00    0.000000           0         1           set_robust_list
  0.00    0.000000           0         1           prlimit64
  0.00    0.000000           0         1           rseq
------ ----------- ----------- --------- --------- ----------------
100.00    0.011605          25       449        73 total

64位Linux系统调用整理

返回值放在%rax

%raxsyscallEntry pointManual
202futexsys_futexfutex(2)
44sendtosys_sendtosendto(2)
11munmapsys_munmapmunmap(2)
435clone3sys_clone3clone3(2)
54setsockoptsys_setsockoptsetsockopt(2)
9mmapsys_mmapmmap(2)
3closesys_closeclose(2)
10mprotectsys_mprotectmprotect(2)
257openatsys_openatopenat(2)
230clock_nanosleepsys_clock_nanosleepclock_nanosleep(2)
41socketsys_socketsocket(2)
87unlinksys_unlinkunlink(2)
48shutdownsys_shutdownshutdown(2)
12brksys_brkbrk(2)
233epoll_ctlsys_epoll_ctlepoll_ctl(2)
14rt_sigprocmasksys_rt_sigprocmaskrt_sigprocmask(2)
262newfstatatsys_newfstatatnewfstatat(2)
49bindsys_bindbind(2)
73flocksys_flockflock(2)
285fallocatesys_fallocatefallocate(2)
1writesys_writewrite(2)
47recvmsgsys_recvmsgrecvmsg(2)
0readsys_readread(2)
51getsocknamesys_getsocknamegetsockname(2)
86linksys_linklink(2)
290eventfd2sys_eventfd2eventfd2(2)
16ioctlsys_ioctlioctl(2)
55getsockoptsys_getsockoptgetsockopt(2)
318getrandomsys_getrandomgetrandom(2)
91fchmodsys_fchmodfchmod(2)
218set_tid_addresssys_set_tid_addressset_tid_address(2)
283timerfd_createsys_timerfd_createtimerfd_create(2)
291epoll_create1sys_epoll_create1epoll_create1(2)
158arch_prctlsys_arch_prctlarch_prctl(2)
273set_robust_listsys_set_robust_listset_robust_list(2)
334rseqsys_rseqrseq(2)
39getpidsys_getpidgetpid(2)
8lseeksys_lseeklseek(2)
13rt_sigactionsys_rt_sigactionrt_sigaction(2)
17pread64sys_pread64pread64(2)
21accesssys_accessaccess(2)
42connectsys_connectconnect(2)
59execvesys_execveexecve(2)
63unamesys_unameuname(2)
107geteuidsys_geteuidgeteuid(2)
302prlimit64sys_prlimit64prlimit64(2)