Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 13 Oct 2003 09:06:41 +0200 (CEST)
From:      Harti Brandt <brandt@fokus.fraunhofer.de>
To:        Tim Kientzle <kientzle@acm.org>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: Dynamic reads without locking.
Message-ID:  <20031013090323.P45269@beagle.fokus.fraunhofer.de>
In-Reply-To: <3F8663AA.4010707@acm.org>
References:  <20031009194644.50B9116A4BF@hub.freebsd.org> <20031010091003.Q95881@beagle.fokus.fraunhofer.de> <3F8663AA.4010707@acm.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 10 Oct 2003, Tim Kientzle wrote:

TK>Harti Brandt wrote:
TK>> Yes. When I read the C standard
TK>> 	foo = data & mask;
TK>> wouldn't also help, because there is no sequence point in this statement
TK>> except at the ;.
TK>
TK>Before anyone takes this particular line of reasoning seriously,
TK>I feel compelled to point out that sequence points have nothing to
TK>do with this.
TK>
TK>a) Sequence points are an "as if" requirement.  The
TK>    program must produce the same results "as if" it
TK>    strictly obeyed sequence points.  It doesn't have
TK>    to really operate that way.  (And, in fact, well-optimized
TK>    programs running on modern processors rarely do.)

And that means, that at the semicolon the value of foo should be "as if"
the compiler really compiled the expression as written. This does not
mean, that he has to and this does mean, that while executing this
expression "foo" can have any value.

TK>b) Sequence points say NOTHING about how multiple
TK>    threads or processors interact.
TK>
TK>Sorry, but the C standard doesn't help here.  The
TK>C standard does not address multi-threading at all.

But it addresses signal handling which suffers from the same problem of
atomic access to variables.

harti
-- 
harti brandt,
http://www.fokus.fraunhofer.de/research/cc/cats/employees/hartmut.brandt/private
brandt@fokus.fraunhofer.de, harti@freebsd.org



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20031013090323.P45269>