[Info-vax] yet another sys$qiow question

John Reagan xyzzy1959 at gmail.com
Wed Aug 19 19:45:21 EDT 2015


On Wednesday, August 19, 2015 at 7:37:14 PM UTC-4, David Froble wrote:
> Johnny Billquist wrote:
> 
> Some of this has caught my attention.
> 
> 
> > Exmaple:
> >   x = iosb;
> >   y = iosb;
> 
> 
> > The C compiler can easily compact this into just one read of the iosb 
> > variable, even if your source code have two reads. And if the system 
> > actaully changed the value between these two reads, then you could argue 
> > that y got the wrong value.
> 
> If this is what you get from optimization, then I got to ask, is optimized code 
> accurate?

>From the language's definition, yes.  No optimizer should change the external behavior of a valid program.  If you try to look, the optimizer should back off.

And yes, without a VOLATILE, why fetch more than once?  Loads are expensive (even ones that resolve from cache).

> 
> > Even more fun:
> > 
> >   while (iosb == 0) ;
> 
> In this case, I'm going to observe that it's poor coding practice.  Why would 
> you tie up the CPU in a loop?  Wouldn't that have an adverse affect on all users?

You wouldn't do this in practice.  You'd use $WAITFR and $SYNCH.




More information about the Info-vax mailing list