Linux PARISC architecture development
 help / color / mirror / Atom feed
From: John Marvin <jsm@udlkern.fc.hp.com>
To: parisc-linux@lists.parisc-linux.org
Subject: Re: [parisc-linux] atomic_t
Date: Sun, 13 Jan 2002 23:54:21 -0700 (MST)	[thread overview]
Message-ID: <200201140654.XAA06768@udlkern.fc.hp.com> (raw)

> >
> > But someone thought it was time to reset the counter. And if
> > it "never happened", then whoever is looking for 'v == 1' will
> > never see it.
>
> It's a race though; they can't guarantee to see it anyway.
>

Yes, it is a race in that you can't be guaranteed that you will ever see
the value equal to 1. But you should be guaranteed that it WAS reset.

For example:

    1) Initialize counter to 1.
    2) Increment counter by 1 each time event "X" occurs using
       atomic_add_return.
    3) Reset counter to 1 each time event "Y" occurs using atomic_set.
    4) Signal an error if the counter ever exceeds some threshold
       value, i.e. it is an error if too many "X" events occur without
       and intervening "Y" event.

In the above scenario you could not be guaranteed that you would ever see
the counter at one (or any particular value), but you could falsely
trigger the error condition if the resets were lost (by removing the
spinlocks from atomic_set).

John

             reply	other threads:[~2002-01-14  6:54 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-01-14  6:54 John Marvin [this message]
  -- strict thread matches above, loose matches on Subject: below --
2002-01-13 21:15 [parisc-linux] atomic_t Matthew Wilcox
2002-01-14  4:09 ` Grant Grundler
2002-01-14  4:43   ` Matthew Wilcox
2002-01-14  7:12     ` Grant Grundler
2002-01-14  9:54   ` Alan Cox

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=200201140654.XAA06768@udlkern.fc.hp.com \
    --to=jsm@udlkern.fc.hp.com \
    --cc=parisc-linux@lists.parisc-linux.org \
    /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