[Info-vax] Volatile, was: Re: yet another sys$qiow question
VAXman- at SendSpamHere.ORG
VAXman- at SendSpamHere.ORG
Thu Aug 20 13:02:12 EDT 2015
In article <55d5f5ae$0$29836$c3e8da3$dbd57e7 at news.astraweb.com>, JF Mezei <jfmezei.spamnot at vaxination.ca> writes:
>On 15-08-20 11:19, John Reagan wrote:
>
>> Correct. If all you do is declare the IOSB, pass it to $QIO and don't read it until the EF or AST is delivered, the lack of volatile is probably not important.
>
>Say I set the IOSB to zeroes,
>call QIOW passing IOSB
>then check IOSB to make sure IO completed with success.
You'd be wasting cycles. They IOSB is cleared by the service to which it
is passed.
>Would the compiler realise that QIOW could modify the IOSB and thus make
>sure that when I check the IOSB, it doesn't assume it is still set to 0s ?
>
>So, if I use QIO instead of QIOW, wouldn't the compiler also flag IOSB
>as potentially having been modified, so the next time it is read, it
>needs to be read from memory ?
C doesn't know squat about $QIO or $QIOW.
>I realise that once in a loop that checks IOSB, the compiler wouldn't
>see any other potential modification of IOSB within the loop and
>optimize it away.
>
>
>I learned that whenever I need to use the debugger, to always
>CC/nooptimize , but never really considered cases where an AST
>modifying a variable (or the driver itself) would not result in my code
>seeing the updated value.
If you use /NOOPTIMIZE then you would probably not know whether or not any
variable should be declared 'volatile'. Take that bit of C code I posted
which uses the 'asm()'. If you compile and run it (assuming /OPTIMIZE),
the IOSB change from I/O completion will not be seen by the while() test.
However, if you compile it /NOOPTIMIZE, it will definitely be noticed. A
quick demonstration of the diffences which can be realized when debugging
code and then compiling it for production.>
--
VAXman- A Bored Certified VMS Kernel Mode Hacker VAXman(at)TMESIS(dot)ORG
I speak to machines with the voice of humanity.
More information about the Info-vax
mailing list