From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9536 invoked by alias); 15 Nov 2004 11:09:40 -0000 Mailing-List: contact pthreads-win32-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: pthreads-win32-owner@sources.redhat.com Received: (qmail 9416 invoked from network); 15 Nov 2004 11:09:30 -0000 Received: from unknown (HELO cedre.telisma-lan.fr) (194.3.30.34) by sourceware.org with SMTP; 15 Nov 2004 11:09:30 -0000 Received: from [192.168.1.78] ([192.168.1.78]) by cedre.telisma-lan.fr with Microsoft SMTPSVC(5.0.2195.6713); Mon, 15 Nov 2004 12:09:29 +0100 Message-ID: <41988E5C.1020201@telisma.com> Date: Mon, 15 Nov 2004 11:09:00 -0000 From: Nicolas EDEL Reply-To: nedel@telisma.com Organization: Telisma User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.2) Gecko/20040803 MIME-Version: 1.0 To: Bastian Voigt CC: pthreads-win32@sources.redhat.com Subject: Re: calling mutex_lock() twice from one thread References: <419888D2.3060502@voigt.in-berlin.de> In-Reply-To: <419888D2.3060502@voigt.in-berlin.de> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 15 Nov 2004 11:09:29.0552 (UTC) FILETIME=[93A37500:01C4CB03] X-SW-Source: 2004/txt/msg00143.txt.bz2 Bastian Voigt wrote: > Dear list, > > according to the documentation pthread_mutex_lock() assigns the mutex to > the calling thread, and if a different thread calls it again it will be > blocked. > > In my scenario I want one thread to block itself, to be waked up later > by a signal handler. This does not work by simply calling mutex_lock() > twice, it does not block. > > What can you recommend to achieve this? To be more concrete, I do the > following: > > The main thread loads some configuration, then starts some worker > threads. After the worker threads are running I want the main thread to > sleep until a signal (Ctrl-C) arrives. Will it work better when using > semaphores? > > Thanks for any hints! > > Bastian Voigt hi, maybe you should have a look at the pthread_cond_t doc & usage. regards --N