Boost logo

Boost Users :

From: joshuaboelter (yahoo_at_[hidden])
Date: 2002-11-15 04:05:43


I've just started using the boost libraries, threads so far -- great
libraries. I have a test app that uses thread groups of producers
and consumers working with a queue. It seems simple enough, but I'm
encountering a deadlock problem using notify_all() vs looping with
notify_one() when ending the consumer threads. I'm not sure my
implementation is correct though (link to source below).

I can reliably cause deadlocks on all Windows XP systems I've tried
(single, dual and quad machines) within about a minute of
execution. However, I only had one deadlock on Windows 2000 (single
or quad) in over 6 hours of execution and still going.

Attaching or running the executable in the VS7 debugger shows all
the threads and the main thread stopped in ntdll.dll via
kernel32.dll. The stack shows the last user code executed by wmain
was boost::thread_group::join_all from ctg.join_all(). The threads
last ran boost::condition::do_wait before entering the kernel.

Swapping lines 217-218 for 222-227 appears to fix the deadlock by
looping with notify_one(). I would guess that something fundamental
is wrong with my implementation, and my fix just changes the
timing. Any help is appreciated.

The source is posted at the link below. I can provide further
information if necessary.

Thanks,
Joshua Boelter

www.boelter.org/data/t_threadgroup.cpp

Using Visual Studio 7.0.9466, stlport 4.5.3 (dll), boost libraries
1.29.0 on various WinXP Pro and Win2k systems.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net