From: LEVITT@SLC.SLAC.STANFORD.EDU (Stevie Boy)
Newsgroups: comp.os.vms
Subject: RE. Asynch. signal from VMS
Date: 22 Jul 92 19:35:00 GMT
Distribution: world
Organization: The Internet

Here is a summary of various suggestions I received regarding getting an
aynchronous signal from VMS whenever a file is written to a directory:

1. Poll for files, process them and then move them to reduce the ammount of
   polling done. I thought about having a logical name PCDIR defined as two
   directories [.TO_DO] & [.DONE] so that the PC could write to and read from
   a single "directory" and be oblivious to the movement of the files. The 
   problem is that although the pathworks "USE" command interprets PCDIR, it
   only yields the first directory it defines. Shame. Still, this method has
   the advantage of simplicity, it gives a handshake capability between the PC
   and the VAX, and the system clocks of the VAX & PC don't have to
   be synchronised as they would if you were to look at file modification time.
   Thanks to both Jim Agnew AGNEW@RUBY.VCU.EDU 
   and Brian Cuttler SYSBRC@ALBNYVMS.ALBANY.EDU

2. Enable ACL alarms on the directory and use the audit server to kick my
   server program. The idea is you create a mailbox and wait for audit
   messages to come in. The SET AUDIT/LISTENER=steve_mbx command will direct a
   copy of all audit messages to the mailbox. The drawback is that ALL audit
   messages arrive, and you have to filter them. There is even an example of
   this mechanism: (at least our installation) SYS$EXAMPLES:AUDSRV_LISTENER.B32
   Thanks to Chris Chiesa CHRIS_F_CHIESA@CUP.PORTAL.COM 
   and Nigel Arnot NRA@IPG.PH.KCL.AC.UK

3. VMS takes out a kernel mode lock on the directory when writing into it.  You
   can let your application take out an exclusive lock on the directory, release
   the lock when it receives a blocking ast, and process the new files when it
   regains the lock.  You can take similar locks on the single files in the
   directory.  The easiest way to find the lock used is through the statistics
   block, you can get from the XCP when you use the QIO interface described I/O
   Users manual.  The FCB field refers the FCB, that contains a field, which
   contains the lock id.  You will need SYSLCK and CMKRNL to do the trick.
   Karsten Nyblad sent me some Bliss 32 code for this, so thanks are
   due to him KARSTEN@TFL.DK

4. Investigate the details of the lock database which RMS uses
   to synchronize access to files. You'll probably need the Files-11 internals
   book if you decide to try this. It MIGHT be possible to set up a lock of
   your own on the .DIR, with a blocking AST. Whem RMS wants to create a file,
   your blocking AST goes off, you downgrade your lock to null, RMS does its
   stuff, you upgrade your lock back to exclusive-write and then scan for the
   new file. Of course, this is assuming that RMS will wait while you un-block,
   rather than immediately giving a "file locked by another user" error.
   Thanks to Nigel Arnot NRA@IPG.PH.KCL.AC.UK

Well folks, there you have it - it can be done, but not neccessarily easily.
Thanks again to those who replied.

--------------------------------------------------------------------------------
Disclaimer: Any ignorance expressed here is my own. It does not imply
            ignorance on the part of SLAC, Stanford University or the DoE.
--------------------------------------------------------------------------------