[Info-vax] Volatile, was: Re: yet another sys$qiow question

Simon Clubley clubley at remove_me.eisner.decus.org-Earth.UFP
Wed Aug 19 13:45:29 EDT 2015


On 2015-08-19, VAXman-  @SendSpamHere.ORG <VAXman- at SendSpamHere.ORG> wrote:
> In article <mr28jf$l0g$1 at dont-email.me>, Simon Clubley <clubley at remove_me.eisner.decus.org-Earth.UFP> writes:
>>On 2015-08-19, VAXman-  @SendSpamHere.ORG <VAXman- at SendSpamHere.ORG> wrote:
>>> Question:  If "volatile" is necessary, shouldn't this code keep spinning its
>>> tail???
>>>
>>
>>No, because you only have a function call in the loop (sys$qiow())
>>(and the function call additionally directly references iosb BTW).
>>
>>This means that regardless of whether the compiler terminates the
>>caching scope for iosb at any function call or whether it only
>>terminates the caching scope when a function call references iosb,
>>your code still causes the compiler to generate code to re-read the
>>current contents of the iosb variable after the function call returns.
>>
>>The current discussion is based around the belief C compilers terminate
>>the caching scope at any function call. I don't know if this is true
>>for all the other languages VMS supports.
>
> So, I should put the $QIO in a subroutine.
>

As the $QIO is already a subroutine (as far a C compiler is concerned)
this will not achieve anything.

The issue arises not when the $QIO is queued, but when it completes.

This is because the VMS $QIO model can directly alter process memory
while the process is busy executing other code, including possibly
checking the contents of the IOSB.

In your example case, you have a single $QIOW which causes the program
to stall until the $QIOW completes. This, combined with the fact that
the caching scope for your iosb variable ends at the call to sys$qiow()
means this will never be a problem for your example program.

In the examples we are talking about, there is a queued $QIO and the
program continues execution while the $QIO is queued. The concern
(at least for me) is that some existing code may break because, for
example, the optimiser in the new compilers is way more aggressive
than the DEC compilers or LLVM may generate otherwise valid code
which has the same effect.

I know from direct experience that you don't get very far with gcc
if you mistakenly don't declare volatile variables _as_ volatile due
to what the gcc optimiser/code generator does to your code and the
concern is that the LLVM optimiser/code generator will do pretty much
the same thing.

Simon.

-- 
Simon Clubley, clubley at remove_me.eisner.decus.org-Earth.UFP
Microsoft: Bringing you 1980s technology to a 21st century world



More information about the Info-vax mailing list