简体   繁体   English

V4L2的线程安全性如何?

[英]How thread-safe is V4L2?

I couldn't find any mention of the thread safety characteristics of V4L2, except for this e-mail from 2008 . 除了2008年的这封电子邮件 ,我找不到V4L2的线程安全特性的任何提法。 It talks about the big kernel lock, which I guess is gone now, right? 它谈论的是大内核锁,我猜这已经不见了,对吧?

Does anybody have any updated information on this? 有人对此有更新信息吗? Can I ioctl (I'm thinking especially about VIDIOC_DQBUF and VIDIOC_QBUF ) the same V4L2 file descriptor from multiple threads without serialization? 可我ioctl (我特别想VIDIOC_DQBUFVIDIOC_QBUF )从多个线程没有序列相同V4L2文件描述符? The discussion cited above does seem to indicate that the answer is driver-dependent, but I thought I'd ask anyway. 上面引用的讨论似乎确实表明答案取决于驾驶员,但我还是想问一下。

The specification does not mention whether V4L2 is thread-safe. 规范没有提到V4L2是否是线程安全的。 However it seems that some implementations actually are thread safe. 但是,似乎某些实现实际上是线程安全的。

POSIX.1-2001 and POSIX.1-2008 require that all functions specified in the standard shall be thread-safe, except some specific functions. POSIX.1-2001和POSIX.1-2008要求标准中指定的所有功能均应是线程安全的,但某些特定功能除外。 ioctl() is not one of them, so it IS thread-safe. ioctl()不是其中之一,因此它是线程安全的。 However, ioctl() is a cancellation point, so the thread can be terminated once it reaches ioctl(). 但是,ioctl()是取消点,因此一旦线程到达ioctl(),就可以终止该线程。

I think that the correct solution is to assume that V4L2 is not thread-safe and do the locking accordingly. 我认为正确的解决方案是假设V4L2不是线程安全的,并相应地进行锁定。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM