  Programming with Event Flags and ASTs? 
 The Question is:
 
I usually run my VMS time critical applications Asynchronously, where I use AST
 routines and event flags. Relating to QIO reads, can you please explain to me:
1) what VMS does with the event flag when the AST fires?
2) when is it okay for the app to clear or set the event flag?
3) what does it mean when the AST fires with a SUSPPENDED IOSB condition and
 what am I supposed to do when I get it?  for example, do I clear the event
 flag and issue the QIO read again?
 
I'd appreciate a quick response and thank you in advance.
 
 
 The Answer is :
 
  Please consider the use of EFN$C_ENF as your event flag, a constant
  that is defined in efndef and that is documented in the documentation.
  Please see topic (1661) and referenced topics for general information
  on asynchronous and AST-based programming.
 
  1: OpenVMS will write to the IOSB, will set the EF, and will then
     trigger the AST, in that order.  In practice, the order of the
     processing of the completion will be consistent and will be
     exactly as you would expect.
 
  2: It is appropriate to clear the EF when there is no outstanding
     asynchronous change pending for the EF.  (Determining when there
     are no asynchronous activities can potentially be an interesting
     challenge.)
 
     All asynchronous system calls are expected to automatically clear
     the specified event flag, when the call is initially invoked.
 
  3: You have received an error from the asynchronous portion of the
     call, and specifically that the target (process?) associated with
     the call is reporting the suspended error.   Given that the AST is
     active, the specified event flag will have been set -- assuming you
     are not using the EFN$C_ENF mechanism, that is.
 
  When an event flag is required and EFN$C_ENF cannot be used, the
  consistent use of lib$get_ef and lib$free_ef is prefered, as this will
  reserve and release event flags in a coordinated and controlled fashion.
  Proper event flag reservation can reduce the contention on event flags,
  though it is still possible for a non-modular application to hijack
  an event flag -- with potential consequences ranging from the obscure
  to the application-catastrophic.
 
  In addition to (1661), also please see (681), (2681), (2922), (5534),
  (6138), (6608), (7629), and likely various other topics.  Topic (7397)
  might also be of some interest here, as will the Internals and Data
  Structures Manual.
 
  The Ask The Wizard area is not in a position to provide a quick or
  a timely or a rapid response, as was hopefully very clearly stated
  in the information posted prior to the question form -- rapid answers
  to most any time-critical or business-critical questions are available
  from the customer support center.
 
 
 Answer written or last revised on  5-FEB-2003 
