Dynamic reads without locking.
Harti Brandt
brandt at fokus.fraunhofer.de
Mon Oct 13 00:07:26 PDT 2003
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 at fokus.fraunhofer.de, harti at freebsd.org
More information about the freebsd-hackers
mailing list