From: Tim Wright <timw@splhi.com>
To: Daniel Phillips <phillips@innominate.de>
Cc: Paul Cassella <pwc@sgi.com>, linux-kernel@vger.kernel.org
Subject: Re: [RFC] Semaphores used for daemon wakeup
Date: Fri, 22 Dec 2000 07:33:19 -0800 [thread overview]
Message-ID: <20001222073319.A2190@scutter.internal.splhi.com> (raw)
In-Reply-To: <3A42B353.D0D249C1@innominate.de> <Pine.LNX.4.21.0012212221220.32526-100000@mindy.americas.sgi.com> <3A433F14.3F3871A5@innominate.de>
In-Reply-To: <3A433F14.3F3871A5@innominate.de>; from phillips@innominate.de on Fri, Dec 22, 2000 at 12:46:28PM +0100
On Fri, Dec 22, 2000 at 12:46:28PM +0100, Daniel Phillips wrote:
[...]
> Granted, it's just an example, but it doesn't make sense to wake up more
> dmabuf_alloc waiters than you actually have buffers for. You do one
> up() per freed buffer, and the semaphore's wait queue better be fifo or
> have some other way of ensuring a task doesn't languish there. (I don't
> know, does it?)
>
Sorry, I could have picked a clearer example. You are correct - it doesn't
make sense to wake up more waiters than you can satify if you know this at
the time. As Paul mentioned, the idea here is that we may have freed
multiple buffers, and so we wake all the consumers and let them fight it out.
At least in DYNIX/ptx, semaphores are exclusively FIFO. This gives wake-one
semantics by default, and prevents starvation.
> > The example wasn't meant to be an ideal use of sv's, but merely as an
> > example of how they could be used to achieve the same behavior as the code
> > that was posted.
>
> Yes, and a third example of the 'unlock/wakeup_and_sleep' kind of
> primitive - there seems to be a pattern. I should at least take a look
> and see if up_down is easy or hard to implement.
>
One general rule to remember is that if you need to take multiple locks, then
you need to always take them in the same order to avoid deadlocks. One
simple, if crude way of doing this if they're not two fixed locks is to
always take the lock with the lower address first. I don't know if this
will help in this case, but it looks like you probably have to play with
the rw locks for the wait queues to make this atomic.
Tim
--
Tim Wright - timw@splhi.com or timw@aracnet.com or twright@us.ibm.com
IBM Linux Technology Center, Beaverton, Oregon
"Nobody ever said I was charming, they said "Rimmer, you're a git!"" RD VI
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/
next prev parent reply other threads:[~2000-12-22 16:04 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <3A42380B.6E9291D1@sgi.com>
2000-12-21 19:30 ` [RFC] Semaphores used for daemon wakeup Paul Cassella
2000-12-21 22:19 ` Tim Wright
2000-12-22 1:12 ` Daniel Phillips
2000-12-22 1:50 ` Daniel Phillips
2000-12-22 4:26 ` Paul Cassella
2000-12-22 11:46 ` Daniel Phillips
2000-12-22 15:33 ` Tim Wright [this message]
2000-12-22 17:25 ` Daniel Phillips
2000-12-22 17:32 ` Brian Pomerantz
2000-12-17 12:06 Daniel Phillips
2000-12-19 0:14 ` Nigel Gamble
2000-12-19 3:34 ` Tim Wright
2000-12-19 13:11 ` Daniel Phillips
2000-12-19 16:07 ` Tim Wright
2000-12-20 1:34 ` Daniel Phillips
2000-12-21 16:28 ` Tim Wright
2000-12-19 9:01 ` Daniel Phillips
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=20001222073319.A2190@scutter.internal.splhi.com \
--to=timw@splhi.com \
--cc=linux-kernel@vger.kernel.org \
--cc=phillips@innominate.de \
--cc=pwc@sgi.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