This is the mail archive of the cygwin@sources.redhat.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Error in sem_init (cygwin-1.1.7-1)


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]