[Info-vax] yet another sys$qiow question
Johnny Billquist
bqt at softjar.se
Wed Aug 19 09:04:20 EDT 2015
On 2015-08-19 04:46, John Reagan wrote:
> On Tuesday, August 18, 2015 at 7:45:35 PM UTC-4, George Cornelius wrote:
>
>>
>> The whole volatile thing appears to have been a distraction. As far as
>> I can tell, the C compiler never issues memory barrier instructions when
>> referencing volatile data, and, as John has pointed out, volatile is
>> not really needed as a hint to the compiler that the data might change
>> asynchronously as long as it already knows that the address of the
>> entity has been taken and passed to external code, because it
>> apparently has an internal implementation of a 'weakly volatile'
>> designation. But if you do not synchronize, and it does change
>> between two successive calls to external code, the compiler is
>> free to remember, say, the value it read the first time in a
>> sequence of uninterrupted local code and not fetch it separately
>> each time thereafter.
>
> You don't need memory barriers. You do need volatile. The IOSB is written behind your back. volatile says we have to re-fetch.
Yes.
> I think you misunderstood my prior posts. Places that only need a 'weak volatile' are places where you took the address of something (for example, put the address of a variable into an item list descriptor) and then call some system service that would write that variable for you. But C doesn't have a weak volatile. You can get away without using volatile, but in general, I'd recommend it at least for documentation purposes.
Not sure what weak volatile would do, as I have not seen the concept.
> You only need memory barriers when you need to define an order of reads & writes to DIFFERENT memory locations. For example, if you have a buffer and a 'buffer-ready' flag, you want a memory barrier between the writes to the buffer and the write to the ready flag to make sure the buffer is indeed written before you set the flag.
Well, it might be that a memory barrier is also called for. In addition
to the IOSB (which is actually two longwords, right?), you also have the
buffer, which is expected to hold the resulting data once the IOSB
indicates the I/O is complete. That buffer might be updated out of order
compared to the IOSB.
But I would hope/assume that the OS would ensure such barriers are in
place here...
Johnny
More information about the Info-vax
mailing list