linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Rusty Russell <rusty@rustcorp.com.au>
To: Linus Torvalds <torvalds@transmeta.com>
Cc: mingo@elte.hu, Matthew Kirkwood <matthew@hairy.beasts.org>,
	Benjamin LaHaise <bcrl@redhat.com>,
	David Axmark <david@mysql.com>,
	William Lee Irwin III <wli@holomorphy.com>,
	linux-kernel@vger.kernel.org
Date: Mon, 25 Feb 2002 12:41:35 +1100	[thread overview]
raw)

Subject: Re: [PATCH] Lightweight userspace semaphores... 
In-reply-to: Your message of "Sun, 24 Feb 2002 17:23:59 -0800."
             <Pine.LNX.4.33.0202241719330.1420-100000@home.transmeta.com> 

In message <Pine.LNX.4.33.0202241719330.1420-100000@home.transmeta.com> you wri
te:
> 
> 
> On Mon, 25 Feb 2002, Rusty Russell wrote:
> >
> > Bugger.  How about:
> >
> > 	sys_sem_area(void *pagestart, size_t len)
> > 	sys_unsem_area(void *pagestart, size_t len)
> >
> > Is that sufficient?  Is sys_unsem_area required at all?
> 
> The above is sufficient, but I would personally actually prefer an
> interface more like
> 
> 	fd = sem_initialize();
> 	mmap(fd, ...)
> 	..
> 	munmap(..)
> 
> which gives you a handle for the semaphore.

No no no!  Implemented exactly that (and posted to l-k IIRC), and it's
*horrible* to use.

> Note that getting a file descriptor is really quite useful - it means that
> you can pass the file descriptor around through unix domain sockets, for
> example, and allow sharing of the semaphore across unrelated processes
> that way.

First, fd passing sucks: you can't leave an fd somewhere and wait for
someone to pick it up, and they vanish when you exit.  Secondly, you
have some arbitrary limit on the number of semaphores.  Thirdly,
someone has to own them.

Consider tdb, the Trivial Database.  There is no "master locking
daemon".  There is no way for the first opener (who then has to create
the semaphores in your model) to pass them to other openers: this is a
library.

With this interface, I can use them on the stack with clone().

Most importantly, I can place the semaphores in a file and have them
persistant.

lock(1), unlock(1) => fast semaphores in shell scripts!
Rusty.
--
  Anyone who quotes me in their sig is an idiot. -- Rusty Russell.

             reply	other threads:[~2002-02-25  1:42 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-02-25  1:41 Rusty Russell [this message]
2002-02-25  1:58 ` your mail Alexander Viro
2002-02-25  2:14   ` Rusty Russell
2002-02-25  3:18     ` Davide Libenzi
2002-02-25  4:02     ` Alexander Viro
2002-02-26  5:50       ` Rusty Russell
2002-02-25 13:16 ` Alan Cox

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=E16fA92-0007en-00@wagner.rustcorp.com.au \
    --to=rusty@rustcorp.com.au \
    --cc=bcrl@redhat.com \
    --cc=david@mysql.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matthew@hairy.beasts.org \
    --cc=mingo@elte.hu \
    --cc=torvalds@transmeta.com \
    --cc=wli@holomorphy.com \
    /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;
as well as URLs for NNTP newsgroup(s).