pthread_cond_signal w/suspended threads

Daniel Eischen deischen at freebsd.org
Wed May 24 23:07:34 UTC 2006


On Wed, 24 May 2006, Kurt Miller wrote:

> I've been working on an intermittent deadlock in
> the jvm and have isolated it to the following issue.
> When multiple threads are waiting on a condition
> variable and some of those threads have been suspended
> with pthread_suspend_np(), there is an expectation that
> pthread_cond_signal() will signal an unsuspended thread
> first. However, the following program shows this is not
> the case on 6.1-release/kse (thr works as expected).
>
> Can kse behavior be changed to signal unsuspended
> threads first?

Relying on this behavior isn't exactly portable, and what
if there are no unsuspended threads when the signal occurs.
A suspended thread would still be signaled in that case.

The whole suspended threads thing is kind of dangerous
anyways.  If one of these threads hold a lock, or is
waiting in some other queue, then deadlock can occur.
I think you need a way of waiting until they are out
of critical regions before you suspend them in order
for this not to cause problems.

-- 
DE


More information about the freebsd-threads mailing list