Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Re(4): semaphores in Darwin



On May 18, 2004, at 8:47 AM, Peter Lovell wrote:
> On May 17, 2004, at 4:13 PM, David Leimbach wrote:
>> Perhaps because they have similar functionality in the mach_semaphore
>> libraries?
>>
>> I don't know why either. I filed a bug about this and it's stil
>> "Open for review".
>
> Hhmmm. Interesting. I wonder just what's to review? I would prefer to
> use Posix semaphores for reasons of code portability, and stay away
> from dependencies on mach. Named Posix semaphores will get the job
> done -- it's just that you have to avoid name collisions with multiple
> processes etc etc.
>
> I'm not complaining about named ones -- if you were only doing one or
> other this would certainly be the better choice. I'm just puzzled
> that, having done the harder one (named), the easier one (memory)
> isn't there.

If you ignore the fact that they can be (and often are) shared between
processes, the memory-based POSIX semaphores are (somewhat) easier.
But if you need to support both shared and non-shared ones, and want a
consistent implementation, they are much trickier.

Why? Because the memory ones don't have a nice handle, like the named
ones do, to hold references to the underlying synchronizer. You have to
tie the reference to the memory itself, somehow. This is something
that, given the split between BSD and Mach virtual memory within the
kernel, we didn't have support for. It effects lots of little things:
like the way copy-on-write must behave for the memory once you
initialize a semaphore in it, using (64-bit) offsets instead of
addresses in the synchronization logic (because each process can share
it at different addresses, or even one process may have it mapped in
multiple places, so you have to use file/memory object offsets instead
of addresses), etc...

We have the underlying support now (much - but not all - went into
Panther/Darwin 7) and we know this is a glaring omission. Does
anything else need to be said? ;-)

--Jim

[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
darwin-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwin-development
Do not post admin requests to the list. They will be ignored.


References: 
 >stabs common symbols relocation (From: Jonas Maebe <email@hidden>)
 >semaphores in Darwin (From: Peter Lovell <email@hidden>)
 >Re: semaphores in Darwin (From: David Leimbach <email@hidden>)
 >Re(4): semaphores in Darwin (From: Peter Lovell <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.