[Info-vax] Volatile, was: Re: yet another sys$qiow question
Johnny Billquist
bqt at softjar.se
Wed Aug 19 11:52:51 EDT 2015
On 2015-08-19 17:35, "VAXman- "@SendSpamHere.ORG wrote:
> Question: If "volatile" is necessary, shouldn't this code keep spinning its
> tail???
>
> #pragma environment save
> #ifndef __NEW_STARLET
> #define __NEW_STARLET New_and_Improved
> #endif
>
> #include <descrip.h> // OpenVMS descriptor structure definitions
> #include <efndef.h> // OpenVMS event flag number definitions
> #include <iodef.h> // OpenVMS $QIO I/O function code definitions
> #include <iosbdef.h> // OpenVMS I/O status block structure definitions
> #include <starlet.h> // OpenVMS system service prototype & codes
> #include <stsdef.h> // OpenVMS system message format definitions
>
> int main()
> {
> int sts = 0, ctr = 0;
> IOSB iosb = { 0, 0, 0};
>
> unsigned short channel;
> $DESCRIPTOR(sys$output,"SYS$OUTPUT");
>
> char star[] ={'|','/','-','\\'};
>
> if (!((sts=SYS$ASSIGN(
> &sys$output, // device name
> &channel, // channel
> 0, // access mode
> 0 // mailbox name
> ))&STS$M_SUCCESS)) return sts;
>
> while (iosb.iosb$w_status == 0)
> {
> if (!((sts=SYS$QIOW(
> EFN$C_ENF, // event flag number
> channel, // channel
> IO$_WRITEVBLK, // QIO function
> &iosb, // I/O status block
> 0, // AST address
> 0, // AST parameter
> &star[(ctr++)&3], // P1: VA of buffer
> 1, // P2: number of bytes
> 0, // P3: n/a
> 0x8D000000, // P4: carriage control
> 0, // P5: n/a
> 0 // P6: n/a
> ))&STS$M_SUCCESS)) return sts;
> }
> }
>
> #pragma environment restore
First question is (obviousy) how IOSB is defined. (It's a typedef in
some include file, I would assume...)
But that aside this works for the exact reason I talked about before.
SYS$QIOW() is a function call inside the loop. And thus, the compiler
cannot know what gets changed by that function call, so the iosb cannot
be cached between iterations in the loop.
Johnny
More information about the Info-vax
mailing list