Subj : Re: CondVar on Windows : what to do when a consumer thread is killed To : comp.programming.threads From : Alexander Terekhov Date : Fri Jul 01 2005 04:58 pm adebaene@club-internet.fr wrote: [...] > During the singleton destruction, a special message is posted to this > queue to signal the worker thread to stop, and posting to the queue > implies calling pthread_cond_broadcast. > The problem is that, since the singelton is a static object, it's > destructor runs during CRT termination cleanup, *after* the system has > forcibly killed all worker threads --> deadlock :-( So what's the point in calling pthread_cond_broadcast() at process termination time in the last thread ("uncontrolled" evaporation of other threads resulting in broken shared state aside for a moment)? "Doctor, it hurts when I do this. Doctor: Don't do that." ;-) > > > A signal isn't guaranteed to generate > > a spurious wakeup. > What do you mean exactly? There is nothing left to wakeup since the > consumer thread has been killed... > > > If you used pthread cancel then your cleanup > > handlers should have taken care of the problem. > I am working on Windows and do not use pthreads, but Win32 threading > API (in fact, my condvar hasn't got exactly the pthread_condvar > interface - although it has the same semantic). All Schmidt's "condvars" are busted. See pthreads-win32. regards, alexander. .