[Info-vax] Volatile, was: Re: yet another sys$qiow question
Jan-Erik Soderholm
jan-erik.soderholm at telia.com
Fri Aug 21 08:21:57 EDT 2015
Den 2015-08-21 kl. 14:16, skrev David Froble:
> Johnny Billquist wrote:
>> On 2015-08-20 17:00, Bob Gezelter wrote:
>>> On Thursday, August 20, 2015 at 10:53:01 AM UTC-4, JF Mezei wrote:
>>>> On 15-08-20 10:45, Craig A. Berry wrote:
>>>>> On 8/20/15 8:54 AM, JF Mezei wrote:
>>>>>> So, after reading this, I am still puzzled...
>>>>>>
>>>>>> in DEC-C, how does one declare a variable as "volatile" ?
>>>>>
>>>>> As with any C compiler, using the "volatile" keyword, obviously:
>>>>
>>>> This is the first I ever heard of it, or seen it. And been doing $QIOs
>>>> since late 1980s. Pretty scary eh ?
>>>
>>> JF,
>>>
>>> Actually, not.
>>>
>>> The standard way (as Hoff has said) is to either use an event flag or an
>>> AST. Either of these work as defined, and the OpenVMS IO Post processing
>>> is responsible for ensuring that your memory is in a consistent state
>>> when the IO is "completed".
>>
>> volatile have nothing to do with your memory being consistent. It is
>> about how the compiler is allowed to optimize access to the memory. The
>> memory can hold correct content, but the compiled code never reads it.
>>
>>> The problem arises when one checks the contents of an IOSB upon which
>>> one has not received one of the normal completion indicators (e.g,
>>> spinning on the IOSB contents; checking to see if other IO's have
>>> completed when receiving an AST on a different IO).
>>
>> Uh... No... The problem arises when you repeatedly reads a value. If it
>> isn't declared volatile, the compiler might "know" that the value have
>> not changed from one read to the next, and thus can optimize away
>> subsequent reads.
>>
>> Johnny
>>
>
> Uh... No... The problem arises when rather poor coding practice is used.
That is completely wrong as far as "volatile" is concerned.
> I really would hope that none of the manuals or examples suggests reading
> the IOSB prior to the operation being signaled as complete.
>
> I understand what you're saying the volatile command does, but so far I
> don't think I've seen an example that needs it, except for what I'd
> consider improper coding.
Also completely wrong. There are many cases where proper code will
do the "wrong thing" if symbols/variables are not "volatile".
There have been a few examples posted here in *this* thread
from me and others that shows this. Memory maped I/O ports
is one of the more common cases. Variables that can be
updated out-of-scope from interrupt routines is another.
What you obviously are saying is that you do not understand
how "volatile" works. That's OK.
Note that the general discussion about "volatile", such as is
the section from Johnny that you replied to above, has nothing
*specificaly* with VMS or IOSB to do. It is generaly true.
More information about the Info-vax
mailing list