Mailing-List: contact cygwin-help@sourceware.cygnus.com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe@sources.redhat.com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin@sources.redhat.com>
List-Help: <mailto:cygwin-help@sources.redhat.com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner@sources.redhat.com
Delivered-To: mailing list cygwin@sources.redhat.com
Message-ID: <01C075A3.37A23430.trn@terma.com>
From: Torben Nielsen <trn@terma.com>
To: "'cygwin@cygwin.com'" <cygwin@cygwin.com>
Cc: "'trn@terma.com'" <trn@terma.com>
Subject: Error in sem_init (cygwin-1.1.7-1)
Date: Wed, 3 Jan 2001 16:37:01 +0100
Organization: TERMA Elektronik AS
X-Mailer: Microsoft Internet E-mail/MAPI - 8.0.0.4211
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit

Hi!
The following code sequence fails (does not wait):

	sem_t sem;
	sem_init(&sem, 0, 0);
	sem_wait(&sem);

I believe the reason is found in ./winsup/cygwin/thread.cc line 437 (20001228 snapshot):

	item->win32_obj_id = ::CreateSemaphore (&sec_none_nih, _v, _v, NULL);

The third parameter is the maximum count for the semaphore, and it is not allowed to be zero or less
according to Microsofts documentation. If I replace this line with

	item->win32_obj_id = ::CreateSemaphore (&sec_none_nih, _v, LONG_MAX, NULL);

the above example works just fine. If possible, I would like a comment on this.

Regards, Torben Nielsen


--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

