mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: New private cond var design
Date: Fri, 15 Aug 2014 16:28:13 -0400	[thread overview]
Message-ID: <20140815202813.GX12888@brightrain.aerifal.cx> (raw)
In-Reply-To: <20140815193536.GA26312@brightrain.aerifal.cx>

On Fri, Aug 15, 2014 at 03:35:36PM -0400, Rich Felker wrote:
> The list also allows us to eliminate the sequence number wrapping
> issue (sadly, only for private, non-process-shared cv's, since
> process-shared can't use process-local memory like this) in one of two
> ways:
> 
> Option 1: If the list elements store the sequence number their waiter
> is waiting on, the signal/broadcast operations can choose a new
> sequence number distinct from that of all waiters.

I don't think this actually works to avoid the sequence number issue,
at least not as-described above, since the sequence number still has
to remain unique even once there's a new instance. If we keep a linked
list that's not instance-specific but covers all instances, though, we
could use it to avoid sequence number reuse, but then some (light, I
think) extra accounting is needed to mark what part of the list is
from previous instances.

> Option 2: Each waiter can wait on a separate futex on its own stack,
> so that sequence numbers are totally unneeded. This eliminates all
> spurious wakes; signal can precisely control exactly which waiter
> wakes (e.g. choosing the oldest), thereby waking only one waiter.
> Broadcast then becomes much more expensive: the broadcasting thread
> has to make one requeue syscall per waiter. But this still might be a
> good design.

I think this design is more elegant, and probably performs better in
the case where only signal is used since spurious wakes are avoided
totally, but somewhat worse when broadcasts are being used.

Rich


  reply	other threads:[~2014-08-15 20:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-15 19:35 Rich Felker
2014-08-15 20:28 ` Rich Felker [this message]
2014-08-17 13:44 ` AW: " Jens Gustedt
2014-08-17 15:44   ` Rich Felker
2014-08-18  4:04 ` Rich Felker

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=20140815202813.GX12888@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=musl@lists.openwall.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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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).