• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: POSIX Semaphores support.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: POSIX Semaphores support.


  • Subject: Re: POSIX Semaphores support.
  • From: Terry Lambert <email@hidden>
  • Date: Tue, 6 Dec 2005 20:32:32 -0800

On Dec 6, 2005, at 12:30 PM, Miguel Filipe wrote:
Hi,

On 12/6/05, Eric Welch <email@hidden> wrote: Miguel,

For some time OSX has had Posix thread support including semaphores.


In that case, my app has a very strange behaviour on OSX, I make use of sem_init(), sem_wait() & sem_post(), and in OSX my threads never wait on sem_wait().

MacOS X supports named POSIX semaphores, but not unnamed POSIX semaphores.


I expect you must be trapping SIGSYS to prevent your program exiting because of an unsupported system call on the call to sem_init(), since it's implementation is a return of the error ENOSYS.


I googled after that problem and saw a lot of "OSX doesn't support POSIX Semaphores", after which I irresponsibly stopped looking for the cause of the problem. Apparently that could be the case in OSX 10.3, but I'm using 10.4.

Is there any kind of peculiarity in how I should use posix semaphores? (header files, semaphore inicialization or linker flags...)

The first thing you should do is #include <unistd.h> and conditionalize your use of POSIX semaphores on the manifest constant _POSIX_SEMAPHORES, e.g.:



#if ((_POSIX_SEMAPHORES - 200112L) >= 0)
/* This platform fully supports POSIX semaphores */
#else
#if defined(__APPLE__)
/* This platform can support POSIX named semaphores, but not unnamed semaphores */
#else
/* this platform requires that I Google code for P/V semaphores and include it here */
#endif
#endif


The proper list was more likely "unix-porting", but that's OK; this question comes up from time to time.

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


References: 
 >POSIX Semaphores support. (From: Miguel Filipe <email@hidden>)
 >Re: POSIX Semaphores support. (From: Eric Welch <email@hidden>)
 >Re: POSIX Semaphores support. (From: Miguel Filipe <email@hidden>)

  • Prev by Date: Re: Race condition in libkern's OSAtomicDequeue()
  • Next by Date: Re: Race condition in libkern's OSAtomicDequeue()
  • Previous by thread: Re: POSIX Semaphores support.
  • Next by thread: Threading and Synchronization in Mass storage driver
  • Index(es):
    • Date
    • Thread