[haiku-bugs] Re: [Haiku] #11208: POSIX semaphores have incorrect sharing semantics

  • From: "hamish" <trac@xxxxxxxxxxxx>
  • Date: Mon, 11 May 2015 21:13:54 -0000

#11208: POSIX semaphores have incorrect sharing semantics
----------------------------+----------------------------
Reporter: hamish | Owner: nobody
Type: bug | Status: new
Priority: normal | Milestone: Unscheduled
Component: System/POSIX | Version: R1/Development
Resolution: | Keywords:
Blocked By: | Blocking:
Has a Patch: 1 | Platform: All
----------------------------+----------------------------

Comment (by hamish):

Attached is a patch which reimplements unnamed POSIX semaphores using the
user_mutex hashtable wait mechanism. Two new system calls are added:
`_user_mutex_sem_acquire` and `_user_mutex_sem_release`.

Unnamed semaphores now consist of an `int32_t` in userspace. Acquires and
releases are done using atomic ops in userspace when the semaphore has no
waiters (when the semaphores value is >= 0). When the semaphore is
contended the value is set to -1 and the system calls are used to acquire
or release.

I've run the POSIX test suite stress tests for semaphores and all seems
well, however I thought I'd post it here for a second opinion first.

--
Ticket URL: <https://dev.haiku-os.org/ticket/11208#comment:3>
Haiku <https://dev.haiku-os.org>
Haiku - the operating system.

Other related posts: