Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com> List-Archive: <http://sources.redhat.com/ml/cygwin/> List-Post: <mailto:cygwin AT sources DOT redhat DOT com> List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs> Sender: cygwin-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin AT sources DOT redhat DOT com Message-ID: <3BF13AEE.3CAE1490@cern.ch> Date: Tue, 13 Nov 2001 16:23:26 +0100 From: "Lassi A. Tuura" <lassi DOT tuura AT cern DOT ch> Organization: Northeastern University, Boston, USA X-Mailer: Mozilla 4.7 [en] (X11; I; Linux 2.2.12-20 i686) X-Accept-Language: en MIME-Version: 1.0 To: Evan Pollan <evan_pollan AT yahoo DOT com> CC: cygwin AT cygwin DOT com Subject: Re: pthread_create -- no callback? References: <20011113143934 DOT 70212 DOT qmail AT web21001 DOT mail DOT yahoo DOT com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit > Is there something I'm doing wrong in the pthread_create call? Yes, from a very superficial reading at least. > void* execute(void* args) { Here, you'll want non-zero `args'... > int status = pthread_create(&_thread, NULL, execute, NULL); ... and here you are passing null (the last argument). Since QueueProcessor::processTasks is not virtual, you are probably calling it with null 'this'. Dunno why it doesn't die soon after that, but I suppose your while loop is failing there and hence the thread returns immediately, and thus joins. BTW, > pthread_mutex_lock(&_mutex); > while (_queue->size() == 0 && !_stopped) { > pthread_cond_wait(&_condition, &_mutex); > } > pthread_mutex_unlock(&_mutex); > > if (_queue->size()>0 && !_stopped) { > t=_queue->front(); > _queue->pop_front(); ... is bad. You'll want to keep the mutex until you've popped the task off the list. Then unlock, then go into the following code section. > Ideas? Any good online pthreads references/faq's that you'd recommend? I hear David Butenhof's "Programming with POSIX Threads" is good: http://cseng.aw.com/book/0,,0201633922,00.html More links at: http://www.humanfactor.com/pthreads/ //lat -- Nothing more completely baffles one who is full of trick and duplicity, than straightforward and simple integrity in another. --Charles Caleb Colton -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/