Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Mime-Version: 1.0 (Apple Message framework v622) In-Reply-To: <20050528161515.GA1323@trixie.casa.cgf.cx> References: <44f83c19cc33e4382680fe3758164ccf AT rehley DOT net> <20050527202823 DOT GB4939 AT trixie DOT casa DOT cgf DOT cx> <0833be552ca5aa00a72ecef822250580 AT rehley DOT net> <20050528161515 DOT GA1323 AT trixie DOT casa DOT cgf DOT cx> Content-Type: multipart/mixed; boundary=Apple-Mail-6--333909952 Message-Id: <1064750c32ec165a486fe7dba0f8b302@rehley.net> From: Peter Rehley Subject: Re: pthreads, cygwin and pthread_mutex_lock not blocking Date: Tue, 31 May 2005 10:15:27 -0700 To: cygwin AT cygwin DOT com X-IsSubscribed: yes --Apple-Mail-6--333909952 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=ISO-8859-1; format=flowed Well, here is a simple test case, but turns out I wasn't using the=20 latest version. I was having the problem on 1.5.12, I haven't been=20 able to get a good build with cygwin 1.5.17-1. It builds and I can run=20 the install script, but when I put the dll in place I see the message=20 "cygheap magic number mismatch detected", and gcc doesn't want to work. I followed the instructions on the FAQ page for building cygwin. Also=20 the only line that I changed was in winsup/cygwin/include/pthread.h,=20 line 56 from #define PTHREAD_MUTEX_DEFAULT PTHREAD_MUTEX_ERRORCHECK to #define PTHREAD_MUTEX_DEFAULT PTHREAD_MUTEX_NORMAL On the unmodified cygwin 1.5.17, the parent lock returns 45 (EDEADLK) On May 28, 2005, at 9:15 AM, Christopher Faylor wrote: > On Fri, May 27, 2005 at 04:35:39PM -0700, Peter Rehley wrote: >> On May 27, 2005, at 1:28 PM, Christopher Faylor wrote: >> >>> On Fri, May 27, 2005 at 10:57:34AM -0700, Peter Rehley wrote: >>>> I'm trying to use pthread in cygwin, and I'm expecting the function >>>> pthread_mutex_lock to block when used. However it is returning=20 >>>> error >>>> 45 (EDEADLK). I'm using a static initializer for the thread so=20 >>>> the >>>> mutex is type PTHREAD_MUTEX_DEFAULT. >>>> When I look through the pthread code I see that=20 >>>> PTHREAD_MUTEX_DEFAULT >>>> is set to PTHREAD_MUTEX_ERRORCHECK, >>>> When I do the same on linux or soloris, the pthread_mutex_lock=20 >>>> blocks, >>>> and looking in the pthread.h file on those systems see that the >>>> default is set to PTHREAD_MUTEX_NORMAL. >>>> >>>> Why is cygwin using PTHREAD_MUTEX_ERRORCHECK as the default? And=20 >>>> what >>>> problems might occur if PTHREAD_MUTEX_DEFAULT is set to >>>> PTHREAD_MUTEX_NORMAL? >>> >>> Why not just try it and report the results? >> Done. Hangs at WaitForSingleObject. > > Can you provide a STC(tm) (simple test case) which demonstrates the > problem both with and without PTHREAD_MUTEX_ERRORCHECK? > > 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=F8=F8se once bit my sister --Apple-Mail-6--333909952 Content-Transfer-Encoding: 7bit Content-Type: text/plain; x-unix-mode=0744; name="fork_test.c" Content-Disposition: attachment; filename=fork_test.c #include #include #include pthread_mutex_t mutex; void signal_rec(int sig_num) { printf("The child is done\n"); pthread_mutex_unlock(&mutex); } int main(int argc, char *argv[]) { int ret_value; signal(SIGCHLD, signal_rec); mutex=PTHREAD_MUTEX_INITIALIZER; ret_value=pthread_mutex_lock(&mutex); printf("thread locked %d\n",ret_value); ret_value=fork(); if (ret_value==0) { printf("I'm the child\n"); sleep(5); printf("ahh, what a good nap\n"); } else { printf("I'm the parent\n"); // sleep(10); ret_value = pthread_mutex_lock(&mutex); printf("heh, I'm done %d\n",ret_value); } return 0; } --Apple-Mail-6--333909952 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed --Apple-Mail-6--333909952 Content-Type: text/plain; charset=us-ascii -- 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/ --Apple-Mail-6--333909952--