Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 17 Oct 2008 19:44:58 -0400 (EDT)
From:      Daniel Eischen <deischen@freebsd.org>
To:        Kurt Miller <kurt@intricatesoftware.com>
Cc:        freebsd-gnats-submit@freebsd.org, freebsd-threads@freebsd.org
Subject:   Re: threads/128180: pthread_cond_broadcast() lost wakup
Message-ID:  <Pine.GSO.4.64.0810171941410.20136@sea.ntplx.net>
In-Reply-To: <200810171640.m9HGexJ1090893@www.freebsd.org>
References:  <200810171640.m9HGexJ1090893@www.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 17 Oct 2008, Kurt Miller wrote:

> The test program outputs periodic printf's indicating
> progress is being made. When it stops the process is
> deadlocked. The lost wakeup can be confirmed by inspecting
> the saved_waiters local var in main(). Each time the
> deadlock occurs I see that saved_waiters is 8 which tells
> me all eight worker threads were waiting on the condition
> variable when the broadcast was sent. Then switch to the
> thread that is still waiting on the condition variable,
> and you can see that the last_cycle local var is one behind
> the cycles global var which indicates it didn't receive the
> last wakeup.

The test program doesn't look correct to me.  It seems possible
for only a few of the threads (as little as 2) to do all the
work.  Thread 1 can start doing work, then wait for a broadcast.
Thread 2 can start doing his work, then broadcast waking thread 1.
I think you need separate condition variables, one to wake up
the main thread when the last worker goes to sleep/finishes,
and one to wake up the workers.

-- 
DE



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.GSO.4.64.0810171941410.20136>