; ; RCVEVE/RCVEVD - PL/I callable routines to enable/disable an AST ; to set an event flag when the task receives data (i.e., when another ; task sends to it). Useful for waiting until there's data to receive, ; for waiting on a logical OR of event flags, or for testing for data sent ; without receiving it. Does not apply to SNDS/RCVS/RCVAS, since they ; already wait for data by stopping. ; ; calling sequence: ; ; CALL RCVEVE(dsw); /*clears event flag & enables event flag setting*/ ; ; CALL RCVEVD(dsw); /*disables event flag setting*/ ; ; where dsw is a FIXED BIN(15) variable to receive the directive status word. ; ; the caller must define the event flag to be set by declaring the external ; variable RCVEVF, like this if the event flag number is 5: ; ; DCL RCVEVF FIXED BIN(15) EXTERNAL INITIAL(5); ; ; ; example of waiting for data: ; ; DCL RCVEVF FIXED BIN(15) EXTERNAL INITIAL(2); ; DCL DSW FIXED BIN(15), NO_DATA FIXED BIN(15) STATIC INITIAL(-8 /*IE.ITS*/); ; DCL PACKET(15) FIXED BIN(15); ; . . . ; CALL RCVEVE(DSW); IF DSW^=1 THEN (error...); ; DSW = NO_DATA; ; DO WHILE (DSW = NO_DATA); ; CALL RECEIV(RAD50('SENDER'), PACKET, , DSW); ; IF DSW^=1 & DSW^=NO_DATA THEN (error...); ; CALL WAITFR(RCVEVF); ; END; ; /*PACKET NOW HAS DATA*/ ; ; ; Suppose you don't want to hang if your sender task exits, and that ; on its exit event flag SENDER_EXIT is set: ; ; . . . ; CALL RCVEVE(DSW); IF DSW^=1 THEN (error...); ; DSW = NO_DATA; ; DO WHILE (DSW = NO_DATA); ; CALL RECEIV(RAD50('SENDER'), PACKET, , DSW); ; IF DSW^=1 & DSW^=NO_DATA THEN (error...); ; CALL WFLOR(RCVEVF, SENDER_EXIT); /*WAIT FOR EITHER DATA OR SENDER EXIT*/ ; CALL CLREF(SENDER_EXIT, I); /*WAS IS SENDER EXIT?*/ ; IF I = 2 /*IS.SET*/ THEN STOP; /*YES*/ ; END; ; .title RCVEVE ; ; refer to PL/I EXTERNAL variable RCVEVF ; .psect RCVEVF,d,gbl,ovr rcvevf: .blkw 1 .psect ; ; displacements into stack after SAVRG$: ; narg = 16 dsw = narg+2 ; ; macro for executive directives ; ; calling sequence: ; ; exec directive ; .macro exec direc args .mcall direc direc args .endm exec drerr$ ;get names for error codes RCVEVD:: clr r1 br common RCVEVE:: mov #rcvast,r1 common: jsr r0,SAVRG$ exec clef$s rcvevf ;clear the event flag bcs exit exec srda$s r1 cmp $DSW,#IE.ITS bne exit mov #IS.SUC,$DSW ;disabling when already disabled is not an error exit: tst narg(sp) beq nodsw mov $DSW,@dsw(sp) nodsw: rts pc rcvast: exec setf$s rcvevf exec astx$s br . .end