[gst-devel] Multi-threaded queueing locking issues

Brent Bradburn brentb at ridgerun.com
Tue Mar 20 22:44:53 CET 2001


Brent Bradburn wrote:

> In other words, to avoid a deadlock, verify that you still WANT to wait AFTER you
> acquire the lock.  Don't wait if you don't have anything to wait on (the logical
> condition is already satisfied):
>
>               pthread_mutex_lock(&mut);
>               while (x <= y) {
>                       pthread_cond_wait(&cond, &mut);
>               }
>               /* operate on x and y */
>               pthread_mutex_unlock(&mut);

Another approach (and the one I typically use) is POSIX semapores (sem_post(),
sem_wait(), ...).  Posting a semaphore increases the count regardless of whether or
not anyone is currently waiting on it.  This effect can be used to avoid race
conditions without requiring additional application logic (e.g. mutexes).

-------------- next part --------------
A non-text attachment was scrubbed...
Name: brentb.vcf
Type: text/x-vcard
Size: 237 bytes
Desc: Card for Brent Bradburn
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20010320/3cc8e776/attachment.vcf>


More information about the gstreamer-devel mailing list