From: Sape Mullender <sape@huygens.org>
To: 9fans@cse.psu.edu
Subject: Re: [9fans] qunlock
Date: Thu, 24 Jun 2004 09:30:22 -0400 [thread overview]
Message-ID: <46f7f6c603513986b01e8db2581621cb@plan9.bell-labs.com> (raw)
In-Reply-To: <e7bb12a51d39ea1b0cd4adaa8d5c5cf7@davidashen.net>
> The purpose is to have multiple producers and consumers on an queue
> with exclusive access, with priority always given to consumers if there
> are waiting ones and the queue is not empty.
I can imagine one would want to give priority to consumers over producers,
but the danger is that the performance gained by such a thing is more than
offset by the cost of the mechanism.
Putting something on a queue or taking something off is not an expensive
operation. The number of instructions needed is typically somewhere between
a dozen and a gross.
The queue must be protected by a lock (unless one uses a non-blocking queue
implementation, but that's another story). QLocks themselves also have queues
and they, in turn, are protected by spin locks.
If your queue is fairly light weight, I would recommend just using lock() and
unlock() to protect them. When you try to lock when it's already locked, you'll
waste cycles by spinning (but fewer than you might think), but when you use
qlocks — and especially when you use three of them — you'll end up wasting far
more cycles.
I'd say forget about giving priority to consumers; it's not worth it.
Sape
next prev parent reply other threads:[~2004-06-24 13:30 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-06-22 6:04 dvd
2004-06-22 8:06 ` C H Forsyth
2004-06-22 9:09 ` C H Forsyth
2004-06-22 14:19 ` ron minnich
2004-06-22 14:38 ` boyd, rounin
2004-06-22 15:13 ` Rob Pike
2004-06-23 20:11 ` dvd
2004-06-23 20:24 ` Rob Pike
2004-06-23 21:00 ` dvd
2004-06-23 21:12 ` boyd, rounin
2004-06-24 7:19 ` Fco. J. Ballesteros
2004-06-24 10:58 ` dvd
2004-06-24 7:34 ` Fco. J. Ballesteros
2004-06-24 11:02 ` dvd
2004-06-24 11:14 ` Fco. J. Ballesteros
2004-06-24 12:18 ` dvd
2004-06-24 13:09 ` Fco. J. Ballesteros
2004-06-24 13:30 ` Sape Mullender [this message]
2004-06-24 13:47 ` boyd, rounin
2004-06-24 13:42 ` boyd, rounin
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=46f7f6c603513986b01e8db2581621cb@plan9.bell-labs.com \
--to=sape@huygens.org \
--cc=9fans@cse.psu.edu \
/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).