delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/07/06/18:41:51

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Date: Sun, 7 Jul 2002 00:40:42 +0200 (CEST)
From: Clemens Fuchslocher <clfuit00 AT fht-esslingen DOT de>
To: <cygwin AT cygwin DOT com>
Subject: 1.3.12: pthread mutex - second lock won't block.
Message-ID: <57370207062339390-100000@foo>
MIME-Version: 1.0

hi,

If I lock a fast mutex twice, it normaly should block forever. But I
can't reproduce that behavior under the current cygwin version. The
mutex won't block after the second lock. The behavior under cygwin
is similar to a recursive mutex. What's wrong?


Test.c:
-=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-=
/* gcc -Wall -lpthread test.c -o test */

#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>

#define __USE_GNU
#include <pthread.h>

pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;

int main (void)
{
   int ret;

   if ((ret = pthread_mutex_lock (&lock)) != 0)
   {
      printf ("pthread_mutex_lock (): %s\n", strerror (ret));
      return EXIT_FAILURE;
   }

   if ((ret = pthread_mutex_lock (&lock)) != 0)
   {
      printf ("pthread_mutex_lock (): %s\n", strerror (ret));
      return EXIT_FAILURE;
   }

   printf ("DEADBEEF!\n");

   return EXIT_SUCCESS;
}
-=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-=



Under Linux and SunOS the second lock will cause a deadlock.
-=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-=
zero:~$ uname -a
Linux foo 2.4.18 #1 Thu Jul 4 22:49:55 CEST 2002 i686 unknown
zero:~$ /lib/libc.so.6 | head -1
GNU C Library stable release version 2.2.5, by Roland McGrath et al.
zero:~$ gcc -Wall -lpthread test.c -o test
zero:~$ ./test

zero:~> uname -sr
SunOS 5.6
zero:~> gcc -Wall -lpthread test.c -o test
zero:~> ./test

-=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-=



Under cygwin the second lock will not block.
-=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-=
~$ uname -a
CYGWIN_98-4.10 GADGET 1.3.12(0.54/3/2) 2002-07-03 16:42 i686 unknown
~$ gcc -Wall -lpthread test.c -o test
~$ ./test.exe
DEADBEEF!
~$
-=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-=

-- 
:)


--
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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019