Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
Mime-Version: 1.0 (Apple Message framework v622)
In-Reply-To: <20050609155759.GA29880@trixie.casa.cgf.cx>
References: <CA96D22FEF0C7B43AC813F3A1DE435D02CEC98@SERVER.CTCHOME.COM> <eac85ec28df9efcb45670bda423c92e1@rehley.net> <20050609155759.GA29880@trixie.casa.cgf.cx>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Message-Id: <ab8f9795acb0eb27f461bd68c998d259@rehley.net>
From: Peter Rehley <peter@rehley.net>
Subject: Re: PTHREAD_MUTEX_DEFAULT different for cygwin v.s. linux.
Date: Thu, 9 Jun 2005 13:51:52 -0700
To: cygwin@cygwin.com
X-IsSubscribed: yes
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id j59Kq8ZY007464


On Jun 9, 2005, at 8:57 AM, Christopher Faylor wrote:

> On Wed, Jun 08, 2005 at 03:29:46PM -0700, Peter Rehley wrote:
>> On Jun 8, 2005, at 2:59 PM, Thomas E. Zerucha wrote:
>>
>>> I have a problem similar to that of:
>>>
>>> http://sourceware.org/ml/cygwin/2005-05/msg01400.html
>>>
>>> I have an old system that I'm trying to port that uses pthreads, but
>>> doesn't set the attribute, and a non-owner thread will destroy the
>>> thread in a deallocate routine, but this won't happen (it won't
>>> actually destroy the thread).
>>>
>>> The problem is that (in pthread.h) PTHREAD_MUTEX_DEFAULT is .._NORMAL
>>> on linux, the system was originally written for.  It works but
>>> eventually dies when it runs out of threads or mutexes or something
>>> since it can't recycle.  PTHREAD_MUTEX_DEFAULT is .._ERRORCHECK on
>>> cygwin.
>>>
>>> It would be painful to add a whole section to create an attribute
>>> structure just to set this to be the same as linux.
>>
>> If you look at the test case you will see a line that says
>> mutex=PTHREAD_MUTEX_INITIALIZER;
>>
>> This causes the program to use the default (ERRORCHECK) mutex.  To get
>> a normal mutex, you can use mutex=PTHREAD_NORMAL_MUTEX_INITIALIZER_NP;
>>
>> However, in the test case when NORMAL is used, the mutex never gets
>> unlocked because the signal SIG_CHLD doesn't get to the parent.
>
> FWIW, I've changed the default for PTHREAD_MUTEX_INITIALIZER to
> PTHREAD_NORMAL_MUTEX_INITIALIZER_NP in CVS.  Last night I also tried to
> implement handling for interrupting mutexes based on Corinna's
> explanation of what your patch did.
>
Shouldn't PTHREAD_MUTEX_DEFAULT be PTHREAD_MUTEX_NORMAL?

> Both of these changes are in the current snapshot.
And the pthread_mutex_lock is still waiting forever...doesn't process 
the signal.  Looking at the code I think that the pthread_mutex::_lock 
function should be using the cancelable_wait routine in place of the 
WaitForSingleObject.


>
> cgf
>
> --
> Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
> Problem reports:       http://cygwin.com/problems.html
> Documentation:         http://cygwin.com/docs.html
> FAQ:                   http://cygwin.com/faq/
>
>
>
Enjoy,
Peter
-------------------------------
A Møøse once bit my sister


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


