[x264-devel] Updated (and hopefully final) threaded slicetype patch

Leon Woestenberg leon.woestenberg at gmail.com
Tue Apr 7 22:41:15 CEST 2009


Hello,

On Tue, Apr 7, 2009 at 8:08 PM, David DeHaven <dave at sagetv.com> wrote:
> No, it does not need to be (and may not behave properly if the mutex is
> still locked when the broadcast is done).
>
Explain please why it would not behave properly.

I think it will behave properly:

The wait()ing thread is set to runnable state once the condition
variable is signal()ed on and will become waiting on the mutex. Once
the signal()ing thread has unlocked the mutex, the waiting thread
becomes runnable and will run when scheduled.

Apart from that, you may be right that the deadlock is triggered by
the following bug:

> I can see one potential problem since you don't seem to be limited to two
> threads, it's not spinning on the conditional that pthread_cond_wait is
> waiting on. So if you have say two threads that end up blocking because the
>
Ah, indeed that's still a bug in the code!

The "if" must be converted to "while". From the man page:

"Since the return from pthread_cond_wait() or pthread_cond_timedwait()
does not imply anything about the value of this predicate, the
predicate should be re-evaluated upon such return."

Regards,
-- 
Leon


More information about the x264-devel mailing list