9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Russ Cox <rsc@swtch.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: Re: [9fans] double wakeup disallowed
Date: Wed, 28 Oct 2009 08:29:09 -0700	[thread overview]
Message-ID: <dd6fe68a0910280829s1110fd5dr301a9d422deeb67d@mail.gmail.com> (raw)
In-Reply-To: <17cef04d9649c68289bc9e8c70e6ed15@brasstown.quanstro.net>

> i agree that it's wise to check invariants.  however
> the invarient that there is exactly one wakeup for
> every sleep requires some careful accounting that
> can be equally error prone.

There is no such requirement on callers.

> the case i'm worried about is when two or more kprocs
> think (perhaps for independent reasons) they need to
> wakeup a Rendez.  it would seem to me less error prone
> (and faster) for wakeup to allow this race and do nothing.

It is always legal to call wakeup on a Rendez:

    Wakeup is called by either a process or an interrupt handler
    to wake any process sleeping at r, signifying that the
    corresponding condition is true (the event has occurred).
    It has no effect if there is no sleeping process.

    [http://www.vitanuova.com/inferno/man/10/sleep.html]

Moving from documentation to code, if two different procs
call into /sys/src/9/port/proc.c:/^wakeup on the same r,
one will get the lock first.  That one will find (p = r->p) != nil,
ready(p), and set r->p = nil..  The next will find (p = r->p) == nil
and do nothing.

> e.g., the interrupt routines of, e.g. 82563 and igbe take particular
> care not to double-interrupt.  this requires some extra rts
> across the pci/pcie bus.

If you are referring to the dance with ctlr->im, I suspect that
has much more to do with the peculiarities of the card than
the calling convention for wakeup.

Russ


  reply	other threads:[~2009-10-28 15:29 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <<d73c6a7a4b7a22bffde73a5b0ec7a0b7@terzarima.net>
2009-10-28 13:24 ` erik quanstrom
2009-10-28 15:29   ` Russ Cox [this message]
2009-10-28 15:45     ` Charles Forsyth
2009-10-28 16:14       ` erik quanstrom
2009-10-30  5:45         ` Russ Cox
     [not found] <<dd6fe68a0910292245x70f83d7bl8957356abda38201@mail.gmail.com>
2009-10-30 14:11 ` erik quanstrom
2009-10-27 23:38 erik quanstrom
2009-10-28  9:43 ` Charles Forsyth

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=dd6fe68a0910280829s1110fd5dr301a9d422deeb67d@mail.gmail.com \
    --to=rsc@swtch.com \
    --cc=9fans@9fans.net \
    /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).