Project

General

Profile

Actions

Bug #2337

closed

Wishlist: We need named POSIX semaphores

Added by vsrinivas over 12 years ago. Updated over 10 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
Category:
-
Target version:
-
Start date:
03/26/2012
Due date:
% Done:

0%

Estimated time:

Description

DragonFly is missing named POSIX semaphores (sem_open / sem_close / sem_unlink). python-multiprocessing, for example, needs this to work.

Actions #1

Updated by nthery almost 11 years ago

  • Status changed from New to In Progress
  • Assignee set to nthery

I've got an skeleton prototype roughly similar to the fbsd implementation.

Semaphore names are regular files. Each semaphore has a system-wide state, basically its value, stored in a shared memory region. There is also a per-process state for dealing with multiple sem_open() calls.

The semaphore value is manipulated via atomic instructions. sem_wait() calls into the kernel (umtx_sleep()) if and only if the calling thread must sleep (semaphore value < 0). Similarly sem_post() calls into the kernel (umtx_wakeup()) if and only if there are waiters (value 0 >1). umtx_sleep() could be replaced in a subsequent step with a semaphore-optimized syscall for avoiding user<>kernel transitions when several threads concurrently call sem_wait() with value <= 0.

I'll post the code when fleshed out and cleaned up.

Actions #2

Updated by jalcazar almost 11 years ago

I haven't had enough time but, I did some research and was going to do the same thing (implement it similarly to FreeBSD).
https://github.com/user454322/DragonFlyBSD/commit/c0cb95785623c67b20d74bf759048d3d676e6b76

nthery: Keep up the work
=)

Actions #3

Updated by jorisgio over 10 years ago

  • Status changed from In Progress to Resolved

Implemented by commit 1a09a5c7d3dc38e61fc28441d066b071ad659dc0

Actions

Also available in: Atom PDF