Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: cross-process timeoutable semaphores
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: cross-process timeoutable semaphores

On 11 Nov 2009, at 22:18, Tyler Sample wrote:

> I'm trying to port some linux code to OSX, and have the need for a cross-process timeoutable semaphore (semtimedop in particular being in the original code).  This has been extremely frustrating and I'm about two weeks into trying to implement this basic mechanism (that took me about 2 hours to port from win32 to linux originally).


> My last attempt has been using mach semaphores.  My problem there is poor documentation.  Even after studying mach and its various headers for a couple solid days, I just have no idea how to say to interested processes (which are anonymous, although with significant work I could probably change that) "here's the global port/semaphore name...request the access you need."  I'm really not sure how well it will work since only one task/process can have receive rights on a semaphore/port at the same time anyway.

Hi Tyler,

I think you might find the following blog post (which I just wrote) interesting:


It's supposed to be a very simple example of how one might go about achieving what you were asking for here using the Mach APIs, which, as you point out, are a little difficult to "get" at first.  The book "Programming under Mach" is quite a handy reference, as is Amit Singh's "Mac OS X Internals: A Systems Approach".

Not entirely sure what Apple's people would say about this; IIRC they have said once or twice that use of the Mach API by third-parties is "discouraged", but in this particular instance it seems to be a reasonable solution to your specific problem.

Kind regards,



Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

 >cross-process timeoutable semaphores (From: "Tyler Sample" <email@hidden>)

Visit the Apple Store online or at retail locations.

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.