How thread-safe is V4L2?
Asked Answered
S

1

10

I couldn't find any mention of the thread safety characteristics of V4L2, except for this e-mail from 2008. 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? The discussion cited above does seem to indicate that the answer is driver-dependent, but I thought I'd ask anyway.

Sextodecimo answered 18/4, 2012 at 20:52 Comment(0)
F
4

The specification does not mention whether V4L2 is thread-safe. 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. ioctl() is not one of them, so it IS thread-safe. However, ioctl() is a cancellation point, so the thread can be terminated once it reaches ioctl().

I think that the correct solution is to assume that V4L2 is not thread-safe and do the locking accordingly.

Familiarize answered 26/4, 2012 at 15:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.