[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20111023143137.78c1f9c4@notabene.brown>
Date: Sun, 23 Oct 2011 14:31:37 +1100
From: NeilBrown <neilb@...e.de>
To: Alan Stern <stern@...land.harvard.edu>
Cc: John Stultz <john.stultz@...aro.org>,
"Rafael J. Wysocki" <rjw@...k.pl>,
mark gross <markgross@...gnar.org>,
Linux PM list <linux-pm@...r.kernel.org>,
LKML <linux-kernel@...r.kernel.org>
Subject: Re: lsusd - The Linux SUSpend Daemon
On Sat, 22 Oct 2011 12:31:58 -0400 (EDT) Alan Stern
<stern@...land.harvard.edu> wrote:
> On Fri, 21 Oct 2011, Alan Stern wrote:
>
> > > Maybe we could do something with futexes...
> >
> > Not easily -- as far as I can tell, futexes enjoy relatively little
> > support. In any case, they provide the same service as a mutex, which
> > means you'd have to build a shared lock on top of them.
>
> It occurred to me that we could create a new type of special file, one
> intended to help with interprocess synchronization. It would support
> locking (shared or exclusive, blocking or non-blocking) and the poll
> system call -- the file would appear to be ready for reading whenever a
> shared lock wouldn't block and ready for writing whenever an exclusive
> lock wouldn't block. Actual reads and writes wouldn't have to do
> anything, although maybe someone could suggest a use for them.
>
> Alan Stern
Tempting... We would need a good case to get something included, but not to
just experiment.
The approach that I would take would probably be to extent flock() with a new
flag, e.g. LOCK_POLL.
then
flock(fd, LOCK_EX | LOCK_POLL)
would try to get a non-blocking exclusive lock on 'fd'. If that didn't
succeed it would insert a 'block' anyway [locks_insert_block()] and arrange
so that when the lock might succeeds, fd gets marked to say that 'lock' might
succeed.
Then POLLPRI becomes enabled and select will trigger if the fd is listed in
the 'exceptfds'.
I would then extend that so that lease breaking and dnotify notifications
could come through select/poll rather than as signals...
But this is probably going somewhat off-topic.
NeilBrown
Download attachment "signature.asc" of type "application/pgp-signature" (829 bytes)
Powered by blists - more mailing lists