Reputation: 11227
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.
Upvotes: 10
Views: 1974
Reputation: 25386
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.
Upvotes: 4