[Info-vax] yet another sys$qiow question

Craig A. Berry craigberry at nospam.mac.com
Thu Aug 20 16:19:45 EDT 2015


On 8/20/15 1:55 PM, Johnny Billquist wrote:
> On 2015-08-20 16:42, Craig A. Berry wrote:

>> I think the emphasis here should be on "poorly written program"; I
>> certainly don't see any examples of what you're talking about in
>> SYS$EXAMPLES and I don't see how anyone using the documented methods for
>> making sure the I/O is complete before checking the IOSB would get into
>> this kind of trouble.
>
> One example that I could think of, that might not be so poorly written
> code, which could bite you, would be something like:
>
> SYS$QIO(<arguments>);
> if (iosb == 0) {
>    <do some stuff>
>    <wait for I/O completion>
>    printf("IOSB is now %x\n", iosb);
> }
>
> which would, with a good optimizing compiler, and iosb not declared as
> volatile, an output showing that iosb was 0, even though it actually
> would not be zero.

Doubtful, because you would normally be passing the address of the IOSB
to SYS$QIO, so the compiler would know that the world outside this
routine may be modifying it. If it were while instead of if, then yes,
the compiler might cache the value after the first read. But either way
you are not checking for whether the I/O is complete *before* checking
the IOSB. For code written like that, all bets are off now -- no need to
wait for a new or different compiler.



More information about the Info-vax mailing list