[Info-vax] yet another sys$qiow question
George Cornelius
cornelius at eisner.decus.org
Mon Aug 17 23:20:07 EDT 2015
In article <afee04fb-6dca-4005-a1be-dbe2200ed14b at googlegroups.com>, John Reagan <xyzzy1959 at gmail.com> writes:
> On Tuesday, July 21, 2015 at 3:13:25 AM UTC-4, George Cornelius wrote:
>
>> sys$synch(...);
>> if ( buf[0] == 'Y' )
>> process_successful_completion();
>>
>> do I really know the compiler did not choose to prefetch
>> buf[0] sometime ahead of the time the sys$synch() was issued,
>> since, after all, the sys$synch() call does not reference the
>> buffer at all? I certainly cannot assume the compiler knows
>> what a sys$synch() is and will change its code generation
>> based upon its presence.
>>
>> George
>
> Since you took the address of 'buf' for the $QIO, the C frontend
> tells GEM that the address was taken (think 'weak volatile').
> That should then cause the call to $SYNCH to be a fence.
Thank you for that answer John. Fills in the missing piece.
Volatile seems too extreme, forcing the compiler to generate code to
fetch the data unnecessarily, and a 'weakly volatile' concept that
allows the compiler to optimize fetches between external calls makes
a lot of sense.
Of course, I have been coding under an assumption that something like
that existed without really knowing it just by following the examples
in places such as the system services guide, but could not explain _why_
it worked.
George
More information about the Info-vax
mailing list