[Info-vax] LLVM, volatile and async VMS I/O and system calls

Simon Clubley clubley at remove_me.eisner.decus.org-Earth.UFP
Fri Sep 24 14:36:40 EDT 2021


On 2021-09-24, chris <chris-nospam at tridac.net> wrote:
> On 09/24/21 13:16, Simon Clubley wrote:
>> On 2021-09-23, chris<chris-nospam at tridac.net>  wrote:
>>>
>>> If you look at that use of volatile, it's dealing with sig_atomic,
>>> which I would guess to be an interface to a test and set instruction,
>>> which is  designed to be indivisible and non interuptable. That is,
>>> the whole instruction always executes to completion.
>>> More like driver level code, not application, where such
>>> functionality would normally be encapsulated into a system call.
>>>
>>
>> Volatile is also set (quite correctly) on the buffer itself.
>>
>
> Why ?. While the compiler will typically pad out structures to align
> each element to the machine wordsize, the use of volatile to define
> that buffer looks redundant, since no optimisation would apply to
> that structure definition anyway.
>

Chris, what makes you think you know better than the people who
wrote that header ?

It's not the structure, but the data written into the buffer by
Linux behind the scenes that the volatile attribute is designed
to address.

The whole point of the AIO interface is that the data is written to
the buffer in your process by Linux while your program is busy doing
something else. In this case, it's behaving in exactly the same way
that sys$qio() is behaving.

You therefore have to force a re-read of the buffer when you later go
looking at it so the compiler doesn't think it can reuse an existing
(and now stale) value.

Simon.

-- 
Simon Clubley, clubley at remove_me.eisner.decus.org-Earth.UFP
Walking destinations on a map are further away than they appear.



More information about the Info-vax mailing list