pthread_cond_signal w/suspended threads

Jason Evans jasone at FreeBSD.org
Thu May 25 17:48:07 UTC 2006


Kurt Miller wrote:
> On Wednesday 24 May 2006 7:07 pm, Daniel Eischen wrote:
>>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.
> 
> Sure, I agree. Right now the only alternative I see is
> to not use pthread_suspend/resume_np and do thread
> suspension with signals the way hotspot does it for
> linux. I'd perfer not to do that if possible.

If the code requires protection from suspension via critical sections, 
it turns out that there's a nearly free lazy approach if you use 
signal-based suspend/resume that is way cheaper than preventative 
locking.  So, although the suspend/resume APIs are seductive, there are 
many situations in which they are actually a pessimization.

Jason


More information about the freebsd-threads mailing list