delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2009/03/03/20:45:24

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_PASS
X-Spam-Check-By: sourceware.org
To: cygwin AT cygwin DOT com
From: Nicholas Sherlock <n DOT sherlock AT gmail DOT com>
Subject: Cygwin PThreads bug?
Date: Wed, 04 Mar 2009 14:29:54 +1300
Lines: 49
Message-ID: <gokli9$s59$1@ger.gmane.org>
Mime-Version: 1.0
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8) Gecko/20051201 Thunderbird/1.5 Mnenhy/0.7.3.0
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/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

Hey everyone,

I'm writing a very thread-intensive application using Cygwin and 
Cygwin's PThreads implementation, and I'm running into a few problems. 
As far as I can tell from the spec:

http://www.opengroup.org/onlinepubs/000095399/functions/pthread_rwlock_rdlock.html

This C program:

#include <stdio.h>
#include <pthread.h>
#include <assert.h>
#include <errno.h>

int main() {
	pthread_rwlock_t rw_lock;

	pthread_rwlock_init(&rw_lock,NULL);

	//Lock it once for read...
	assert(pthread_rwlock_rdlock(&rw_lock)==0);
	
	//Lock it again for read...
	int err=pthread_rwlock_rdlock(&rw_lock);

	printf("Err %d\n", err);

	assert (err==EAGAIN || err==0);

	if (err!=EAGAIN)
	  pthread_rwlock_unlock(&rw_lock);

	pthread_rwlock_unlock(&rw_lock);

	pthread_rwlock_destroy(&rw_lock);
	
	return 0;
}

Should run correctly. That is, the second call to pthread_rwlock_rdlock 
should either succeed (returning zero), having acquired the read lock a 
second time, or it should fail and return EAGAIN, if the number of 
simultaneous allowed read locks has been exceeded. It should not fail 
and return EDEADLK (45), which it is currently doing. Am I reading the 
spec wrong or is Cygwin non-conforming?

Cheers,
Nicholas Sherlock


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

- Raw text -


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