Hi Jim,

The C abstract machine definition doesn't take into account multi-processing
and therefore ignores memory operation reordering as seen by external
observers. Volatile means little more than "don't keep this variable in a
register, it must be accessed directly from memory". It however doesn't
specify anything about whether tha variable can exist in cache, or whether
accesses to it can be reordered around other memory accesses. As long as
volatile variables aren't kept in a register and are accessed directly from
[cached] memory then cache coherency will take care of keeping the cache in
sync with external memory (note that for memory-mapped devices, the device
driver must have disabled caching for that region of memory). The problem
of reordering being dicussed here doesn't result in incorrect values being
read (cache coherency, for example, takes care of that), it's to do with
assumptions being made about the order of memory operations mapping to the
order of operations specified in code. DCLP is based on the assumption that
the order of memory operations occurs in the same sequence as specified in
the source code, and in modern MP systems that is rarely the case.

Regards,

Steven

-----Original Message-----
From: owner-openssl-dev@openssl.org [mailtowner-openssl-dev@openssl.org]
On Behalf Of Jim Schneider
Sent: Friday, 8 April 2005 7:35 AM
To: openssl-dev@openssl.org
Subject: Re: OpenSSL use of DCLP may not be thread-safe on multiple
processors

On Thursday 07 April 2005 16:39, David Schwartz wrote:
A bit off-topic, but...

> If you mean 'volatile', no, that doesn't do anything. Specifically,
> 'volatile' has no special semantics for multi-processors. There may be
> specific compilers where it has such semantics, but the standard
> doesn't provide them.


According to ISO 9899-1990, section 6.5.3:

An object that has volatile-qualified type may be modified in ways unknown
to the implementation or have other unknown side effects. Therefore any
expression referring to such an object shall be evaluated strictly according
to the rules of the abstract machine, as described in 5.1.2.3. Furthermore,
at every sequence point the value last stored in the object shall agree with
that prescribed by the abstract machine, EXCEPT AS MODIFIED BY THE UNKNOWN
FACTORS MENTIONED PREVIOUSLY [emphasis added].

Translation: The compiler can't make assumptions about the state of a
variable marked "volatile", and MUST generate code that writes every result
stored there as well as code that reads the variable EVERY SINGLE TIME it
appears in an expression. It has nothing to do with multi-processor
coherency. Any compiler that generates code that deviates from this (even a
little bit) isn't compliant with the standard.
__________________________________________________ ____________________
OpenSSL Project http://www.openssl.org
Development Mailing List openssl-dev@openssl.org
Automated List Manager majordomo@openssl.org

__________________________________________________ ____________________
OpenSSL Project http://www.openssl.org
Development Mailing List openssl-dev@openssl.org
Automated List Manager majordomo@openssl.org