Linux下进程之间的最低延迟通知方法 [英] Lowest latency notification method between process under Linux

查看:279
本文介绍了Linux下进程之间的最低延迟通知方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找最低的等待时间 IPC,该IPC允许一个进程进入睡眠状态,而另一进程唤醒它.

I'm looking for the lowest latency IPC that allow to put one process to sleep and allow other process to wake it.

我正在寻找最低延迟的方法.到目前为止,一些可能的方法:

I'm looking for the lowest latency method. Some possible methods so far:

  1. 将字节写入管道并从管道中读取.
  2. 将字节写入套接字并从中读取.
  3. 发送信号(杀死)并等待(sigwait)
  4. 使用sem_post/sem_wait

还有其他更好的主意吗?

Any other better ideas?

任何特定于Linux的解决方案也都可以.

Any solution that is Linux specific is fine as well.

推荐答案

通常...操作系统方法之间几乎没有区别.

Generally... There is almost no difference between the OS methods.

设置:

  1. 两个与两个不同CPU有亲和力的进程.
  2. 一个进程休眠(nanosleep)N微秒可测量当前时间 然后通知其他进程.
  3. 其他进程唤醒会测量当前时间,并将其与客户的时间进行比较.
  4. 预热100条通知后,对1000个样本的平均值,标准差,中位数和百分位数95进行计算.
  5. 操作系统:Linux 2.6.35 x86_64
  6. CPU:英特尔i5 M460
  1. Two processes with affinity to two different CPUs.
  2. One process sleeps (nanosleep) for N microseconds measures current time and then notifies other process.
  3. Other process wakes measures current time and compares it to the client's time.
  4. Average, standard deviation, median and percentile 95 is calculated over 1K samples after warm-up on 100 notifications.
  5. OS: Linux 2.6.35 x86_64
  6. CPU: Intel i5 M460

结果:

信号量(sem_wait/sem_post-内核-futex):

Semaphore (sem_wait/sem_post - kernel - futex):

sleep us     mean             median      %95
       1     4.98 ±18.7         3.78     5.04
      10     4.14 ±14.8         3.54     4.00
     100    20.60 ±29.4        22.96    26.96
    1000    49.42 ±37.6        30.62    78.75
   10000    63.20 ±22.0        68.38    84.38

信号(杀死/sigwait)

Signal (kill/sigwait)

sleep us     mean             median      %95
       1     4.69 ±3.8          4.21     5.39
      10     5.91 ±14.8         4.19     7.45
     100    23.90 ±17.7        23.41    35.90
    1000    47.38 ±28.0        35.27    81.16
   10000    60.80 ±19.9        68.50    82.36

管道(管道+写入/读取)

Pipe (pipe + write/read)

sleep us     mean             median      %95
       1     3.75 ±5.9          3.46     4.45
      10     4.42 ±3.5          3.84     5.18
     100    23.32 ±25.6        24.17    38.05
    1000    51.17 ±35.3        46.34    74.75
   10000    64.69 ±31.0        67.95    86.80

套接字(套接字对+读/写)

Socket (socketpair +write/read)

sleep us     mean             median      %95
       1     6.07 ±3.2          5.55     6.78
      10     7.00 ±7.1          5.51     8.50
     100    27.57 ±14.1        28.39    50.86
    1000    56.75 ±25.7        50.82    88.74
   10000    73.89 ±16.8        77.54    88.46

作为参考忙于等待:

sleep us     mean             median      %95
       1     0.17 ±0.5          0.13     0.23
      10     0.15 ±0.3          0.13     0.19
     100     0.17 ±0.3          0.16     0.21
    1000     0.22 ±0.1          0.18     0.35
   10000     0.38 ±0.3          0.30     0.78

这篇关于Linux下进程之间的最低延迟通知方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆