[Info-vax] LLVM, volatile and async VMS I/O and system calls
chris
chris-nospam at tridac.net
Fri Sep 24 10:18:48 EDT 2021
On 09/24/21 13:09, Simon Clubley wrote:
> On 2021-09-23, chris<chris-nospam at tridac.net> wrote:
>>
>> Still doesn't explain why a volatiie keyword might be needed at
>> application level, though I guess there might be a few edge cases...
>>
>
> I'm surprised you are having a hard time seeing it Chris.
>
> Hardware stuffs something directly into process memory outside of
> the flow of execution of a program, hence volatile may be required
> for some programs to tell the compiler to generate code to re-read
> it again.
>
Sorry, but that's incorrect. You are confusing compile time actions
with runtime situations. Present C compilers can have no
knowledge of future dynamic runtime situations where, for example, a
shared buffer may be updated asynchronously by separate processes
and at different times. However, most operating systems have features
to manage such situations to ensure things like mutual exclusion and
deadlock prevention. Os books are full of algorithms for that sort
of thing, as it's so fundamental to OS design.
> VMS stuffs something directly into process memory outside of
> the flow of execution of a program, hence volatile may now be
> required for some programs to tell the compiler to generate code
> to re-read it again.
>
> Simon.
Sorry, but wrong again and it does nothing of the sort. All the
volatile keyword does is to tell the compiler to disable
optimisation across sequence points, ie: eg not unroll loops, not
delete whole sections of apparently redundant code etc, but to
generate code as per the source defines. No added code is or can
be generated to take account of future run time situations.
Check out the Harbison & Steele book for 2 or 3 pages on the
volatile keyword...
Chris
>
More information about the Info-vax
mailing list