Commit graph

6 commits

Author SHA1 Message Date
Sebastian Dröge
29aabc223e omxrecmutex: Fix another race condition when two threads are trying to lock for recursion at the same time 2012-12-20 18:48:21 +01:00
Sebastian Dröge
500410226f omxrecmutex: Fix yet another race condition that resulted in deadlocks 2012-12-20 18:16:43 +01:00
Sebastian Dröge
e026926951 omx: Fix another race condition in the recursive mutex
Between lock() and begin_recursion() it was possible for another thread to
try to do a recursive_lock(). This would block because the mutex was already
locked(), but not ready for recursive locking yet. unlock() would never
happen in the original thread because it was waiting for the other thread
to finish first.

Happened on the Raspberry Pi.
2012-12-20 17:46:36 +01:00
Sebastian Dröge
1c7fcf832e omxrecmutex: Fix a small race condition when unlocking a non-recursive lock 2012-12-20 14:45:18 +01:00
Sebastian Dröge
2481ceb8c4 omx: Update to new GLib thread API 2012-11-12 11:29:48 +01:00
George Kiagiadakis
158775f497 Implement a new custom recursive mutex type and fix locking in callbacks so that in-context calls are allowed.
According to the OMX specification, implementations are allowed to call
callbacks in the context of their function calls. However, our callbacks
take locks and this causes deadlocks if the unerlying OMX implementation
uses this kind of in-context calls.

A solution to the problem would be a recursive mutex. However, a normal
recursive mutex does not fix the problem because it is not guaranteed
that the callbacks are called from the same thread. What we see in Broadcom's
implementation for example is:

- OMX_Foo is called
- OMX_Foo waits on a condition
- A callback is executed in a different thread
- When the callback returns, its calling function
  signals the condition that OMX_Foo waits on
- OMX_Foo wakes up and returns

The solution I came up with here is to take a second lock inside the callback,
but only if recursion is expected to happen. Therefore, all calls to OMX
functions are guarded by calls to gst_omx_rec_mutex_begin_recursion() / _end_recursion(),
which effectively tells the mutex that at this point we want to allow calls
to _recursive_lock() to succeed, although we are still holding the master lock.
2012-05-07 17:01:16 +03:00