From: Davide Libenzi <davidel@xmailserver.org>
To: Brandon Corey <bcorey@engr.sgi.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: Pollable Semaphores
Date: Fri, 21 Jan 2005 16:07:17 -0800 (PST) [thread overview]
Message-ID: <Pine.LNX.4.58.0501211600520.5610@bigblue.dev.mdolabs.com> (raw)
In-Reply-To: <20050121212212.GA453910@firefly.engr.sgi.com>
On Fri, 21 Jan 2005, Brandon Corey wrote:
> I'm trying to find out if there is a pollable semaphore equivalent on Linux.
>
> The main idea of a "pollable semaphore", is a semaphore with a related
> file descriptor. The file descriptor can be used to select() when the
> semaphore is acquirable. This provides a convenient way for users to
> implement code synchronization between threads, where multiple file
> descriptors are already being selected against.
>
> We have a pollable semaphore implementation on IRIX that provides this
> functionality. The API consists of a handful of calls for creation and
> destruction of pollable semaphores, as well as a means to attach them
> to a file descriptor. Beyond that, from the users point of view, they're
> just treated as any other file descriptor.
>
> These calls are routed through a library and then passed off to a kernel
> driver that handles the events. If someone selects against a semaphore
> when it's unaquirable, the driver sleeps on a synchronization variable.
> When the semaphore is subsequently made aquirable, the driver will wake up
> any waiters. Multiple pollable semaphores mixed with other file
> descriptors can be selected against, and a wakeup will occur when any of
> the semaphores become acquirable.
>
> Is anyone aware of any equivalent functionality?
I used pipe-based semaphores when I need that functionality (call psem_down_fd()
to get the pollable fd):
http://www.xmailserver.org/pipe-sem.c
http://www.xmailserver.org/pipe-sem.h
They have the problem of the maximum pipe buffer size that affects the
maximum count, but in my case it was fine. Or at least bugs did not come
biting me at the time ;)
- Davide
prev parent reply other threads:[~2005-01-22 0:13 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-01-21 21:22 Brandon Corey
2005-01-21 21:37 ` Roland Dreier
2005-01-21 23:17 ` Brent Casavant
2005-01-22 3:43 ` Ulrich Drepper
2005-01-22 5:52 ` Chris Wright
2005-01-22 7:05 ` Chris Wright
2005-01-22 7:39 ` Ulrich Drepper
2005-01-22 18:02 ` Chris Wright
2005-01-24 20:42 ` Robert White
2005-01-22 0:07 ` Davide Libenzi [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.LNX.4.58.0501211600520.5610@bigblue.dev.mdolabs.com \
--to=davidel@xmailserver.org \
--cc=bcorey@engr.sgi.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®