X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,KHOP_RCVD_TRUST,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org MIME-Version: 1.0 Date: Mon, 10 Sep 2012 09:36:35 -0400 Message-ID: Subject: No support for sharing unnamed semaphores between processes through shared memory? From: Matt Sexton To: cygwin AT cygwin DOT com Content-Type: text/plain; charset=ISO-8859-1 Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: 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 Hello, I am attempting to port to Cygwin an application that synchronizes between processes using unnamed semaphores in shared memory. Both processes have mapped the shared memory region, one process initializes the semaphore, and both processes perform operations on it. Under Cygwin, the second process, which does not initialize the semaphore, gets an EINVAL error when calling sem_post() on that semaphore. (There is no race condition between the initialization and the posting of the semaphore by the different processes.) Looking in /usr/include/semaphore.h, it appears that a sem_t is typedef'ed as pointer to a struct. In winsup/cygwin/thread.cc, semaphore::init appears to make the value of the semaphore the result of a new operation. This step would seem to preclude the sharing the of the semaphore between processes, since the pointer is only valid in the address space of the first process. Is there no support for sharing unnamed semaphores between processes using shared memory? The man page under Linux documents this use case and does seem to imply that it is part of the POSIX standard. If the use case is not supported, what is the recommended work-around? Named semaphores? Thank you, Matt -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple