- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
Linux 串口使用 low_latency tty 模式安全吗? tty_flip_buffer_push函数被记录为“如果设置了 port->low_latency,则不得从 IRQ 上下文调用它”。然而,无论标志是否设置,许多低级串行端口驱动程序都会从 ISR 调用它。例如,mpc52xx driver calls flip buffer每次从其 FIFO 读取后无条件地执行。
ISR 中的低延迟翻转缓冲区的结果是在 IRQ 上下文中输入线路规则驱动程序。我的目标是从高速 mpc52xx 串行端口读取一毫秒或更短的延迟。设置 low_latency 实现了延迟目标,但它也违反了 tty_flip_buffer_push 的记录先决条件。
最佳答案
这个问题是在 linux-serial on Fri, 19 Aug 2011 上提出的.
不,低延迟通常不安全。
但是,在 3.10.5 low_latency
的特殊情况下是安全的。
以上评论tty_flip_buffer_push
读:
"This function must not be called from IRQ context if port->low_latency is set."
void tty_flip_buffer_push(struct tty_port *port)
{
struct tty_bufhead *buf = &port->buf;
unsigned long flags;
spin_lock_irqsave(&buf->lock, flags);
if (buf->tail != NULL)
buf->tail->commit = buf->tail->used;
spin_unlock_irqrestore(&buf->lock, flags);
if (port->low_latency)
flush_to_ldisc(&buf->work);
else
schedule_work(&buf->work);
}
EXPORT_SYMBOL(tty_flip_buffer_push);
spin_lock_irqsave
的使用/
spin_unlock_irqrestore
使这段代码可以安全地从中断上下文调用。
low_latency
的测试如果设置了,
flush_to_ldisc
被直接调用。这会立即将翻转缓冲区刷新到线路规程,代价是使中断处理时间更长。
flush_to_ldisc
例程也被编码为在中断上下文中使用是安全的。我猜早期版本是不安全的。
low_latency
未设置,则
schedule_work
叫做。调用
schedule_work
是在中断上下文中从“上半部分”调用“下半部分”处理程序的经典方法。这会导致
flush_to_ldisc
在下一个时钟滴答时从“下半部分”处理程序调用。
e0495736
中
tty_buffer.c
的提交.这次提交是对早期代码的重写,因此似乎曾经没有测试。谁添加了测试并修复了
flush_to_ldisc
中断安全没有费心修复评论。
On 10/19/2013 07:16 PM, Jonathan Ben Avraham wrote:
> Hi Peter,
> "tty_flip_buffer_push" is called from IRQ handlers in most drivers/tty/serial UART drivers.
>
> "tty_flip_buffer_push" calls "flush_to_ldisc" if low_latency is set.
> "flush_to_ldisc" calls "mutex_lock" in 3.12-rc5, which cannot be used in interrupt context.
>
> Does this mean that setting "low_latency" cannot be used safely in 3.12-rc5?
Yes, I broke low_latency.
Part of the problem is that the 3.11- use of low_latency was unsafe; too many shared
data areas were simply accessed without appropriate safeguards.
I'm working on fixing it but probably won't make it for 3.12 final.
Regards,
Peter Hurley
low_latency
除非您确定永远不会从支持它的版本更改内核。
Hi,
setserial has low_latency option which should minimize receive latency
(scheduler delay). AFAICT it is used if someone talk to external device
via RS-485/RS-232 and need to have quick requests and responses . On
kernel this feature was implemented by direct tty processing from
interrupt context:
void tty_flip_buffer_push(struct tty_port *port)
{
struct tty_bufhead *buf = &port->buf;
buf->tail->commit = buf->tail->used;
if (port->low_latency)
flush_to_ldisc(&buf->work);
else
schedule_work(&buf->work);
}
But after 3.12 tty locking changes, calling flush_to_ldisc() from
interrupt context is a bug (we got scheduling while atomic bug report
here: https://bugzilla.redhat.com/show_bug.cgi?id=1065087 )
I'm not sure how this should be solved. After Peter get rid all of those
race condition in tty layer, we probably don't want go back to use
spin_lock's there. Maybe we can create WQ_HIGHPRI workqueue and schedule
flush_to_ldisc() work there. Or perhaps users that need to low latency,
should switch to thread irq and prioritize serial irq to meat
retirements. Anyway setserial low_latency is now broken and all who use
this feature in the past can not do this any longer on 3.12+ kernels.
Thoughts ?
Stanislaw
关于linux-device-driver - 与 Linux 串行端口一起使用低延迟模式是否安全?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15504890/
我的 Linux Centos Apache 服务器的性能有问题。我有一个程序(用 c 语言编写)可以同时执行许多 http 请求。这个过程本身看起来非常有效,就好像我可以同时向外部服务器发出 500
我想知道如何将并行端口上的数据引脚设置为高电平和低电平。我相信我可以使用 PyParallel 来实现此目的,但我不确定如何设置特定的引脚。 谢谢! 最佳答案 您在这里谈论的是软件-硬件接口(inte
让我有一个像这样的日期时间索引的数据框: date_time open high low close vol 2018-05-13 18:00:00 70.
在 emacs Octave 模式下,当我输入 M-x run-octave 时,命令会卡住,所以我使用 C-g 进行转义。我可以用 C-x b 切换到 *Inferior Octave* 缓冲区,但
我正在 sklearn 中运行 gridsearchCV,尝试使用此代码找到最佳模型参数。 modelDNN= KerasRegressor(build_fn=build_DNN_model, epo
美好的一天。我想知道 android 存储是否低,它会影响应用程序性能吗?因为同一个应用程序在另一台设备上运行速度很快,而同样的应用程序在另一台设备上非常滞后,后者有 12GB 内存中的 2GB 可用
所以我在列卡上有一个带有索引的表 当我运行时 SELECT COUNT(DISTINCT(card)) FROM table 它返回 490 个不同的条目 但是当我运行的时候 SHOW INDEXES
我正在使用手动方法将二进制转换为十进制。此代码在最后一位为高的情况下工作正常,例如:1001。当最后一位为零 [低] 时会出现错误。例如:1010 应该给出 10 但给出 5,因为没有考虑最后一位。有
我一直在努力优化我的站点和数据库,并且我一直在使用 mysqltuner.pl 来帮助解决这个问题。除了表缓存命中率,无论我在 my.cnf 中将它提高多高,我几乎都得到了正确的结果,我仍然命中大约
深入研究 sprite kit (xcode 5)。我正在使用两个示例程序,1. 创建新项目时包含的默认宇宙飞船示例和 2. 我下载的 Adventure Game。 在 iOS 模拟器中运行这些示例
编辑: 感谢大家在这里提供答案,项目已完成。 https://github.com/0xyg3n/ProcessDaemon/ 如果有人想出可能会更好的多线程解决方案,我想。 我是 C# 的新手,我想
我有一个交换 Word 变量的字节(低/高)的过程(它与 System.Swap 函数执行相同的操作)。该过程在编译器优化关闭时有效,但在编译器优化打开时无效。有人可以帮我解决这个问题吗? proce
我以前听说过这些术语描述语言,例如 C 并不是一种低级语言,C++是中级语言,而Python是一种高级语言。我知道它必须与代码的编译方式以及代码的编写方式有关。但是我想知道的是,什么将语言定义为这三类
我有一个关于 NoSQL 类型数据库的问题,特别是 MongoDB,但它通常适用于大多数键值或基于文档的存储。 NoSQL 的一些卖点是速度和可扩展性,但在我看来,与关系数据库相比,开销很大。 你有很
如果没有此代码,fps 为 60-65。但是当我使用这段代码时,fps 下降到 50。 另一个问题是某些设备上的 FPS 太低。然而,游戏非常简单。我对所有形状使用 ShapeRenderer。游戏在
您好,我的名字是 Ryan,我目前正在开发自己的 2D java 游戏。目前游戏世界中有很多物体。游戏重新开始时,世界会加载 100 棵随机放置的树木,这些树木是使用数组列表和树类制作的。我的游戏使用
很难说出这里问的是什么。这个问题是含糊的、模糊的、不完整的、过于宽泛的或修辞性的,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开它,visit the help center 。 已关
我刚刚将我的 Heroku postgres 数据库从 Kappa 计划(800MB RAM,postgres 9.1)升级到 Ronin 计划(1.7GB RAM,postgres 9.2),但性能
现在我正在使用我的 NSDictionary 并运行所有值的循环以找到低值、高值和计算平均值。 由于我是IOS 的新手,所以我想问问是否有更好的方法来做到这一点。有没有? 谢谢。 最佳答案 这个问题的
我目前正在使用 genuino 101 进行一个项目,我需要通过 i2c 读取大量数据,以填充任意大小的缓冲区。从下图中我可以看到读取请求本身只需要大约 3毫秒,写请求大约 200 纳秒。 但是在同一
我是一名优秀的程序员,十分优秀!