Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!rutgers!ucsd!ucbvax!VENUS.YCC.YALE.EDU!LEICHTER From: LEICHTER@VENUS.YCC.YALE.EDU ("Jerry Leichter ", LEICHTER-JERRY@CS.YALE.EDU) Newsgroups: comp.os.vms Subject: re: Event flags and AST Message-ID: <8808010456.AA24240@ucbvax.berkeley.edu> Date: 24 Jul 88 22:57:00 GMT Sender: daemon@ucbvax.BERKELEY.EDU Organization: The Internet Lines: 47 ...I needed to "synchronize" the running of several processes. Those processes were SPAWNed from different accounts IN THE SAME GROUP. It was easy enough to create a (temporary) event flag cluster that all these processes shared and make 'em all wait for a specific event flag. I did this using two very simple programs that I called WAIT and SIGNAL. Essentially when SIGNAL is run, the WAIT program quits running (the event flag is set). What I need to do is the following: I need to declare an AST routine in a program. The AST routine should be called when (preferably) an event flag is set. Problem is I could not find a way to let the program run - apparently you must WAIT for the event flag to be set. I need to let the program There is no way to have an AST triggered by the setting of an event flag. If you step back from this way of looking at things, and simply ask for a way for a process to set off an AST in another process, things are a bit different. Unfortunately, VMS provides no direct way to do exactly this; but you can get the effect in at least three ways, listed in order of increasing performance and difficulty of implementation. 1. Use a mailbox. A process can get an AST when data is placed in a mailbox, or a completion AST if it has a pending read on the mailbox. The mailbox message can carry additional data describing the reason for the AST if you like, or it can be a dummy message. 2. Use the lock manager and blocking AST's. The trick is for the receiver to hold a lock, requesting a blocking AST. The sender attempts to obtain a lock, which the receiver's lock will not allow. The receiver then receives a blocking AST. The code needs to be organized carefully so that the initial state is restored after the "cross-process AST" has been sent (unless you never intend to send another one). For good efficiency, you should actually take out the lock only once, and use lock conversions thereafter. This method, unlike the other two, will work cluster-wide. 3. If you are a kernel-mode hacker, it isn't hard to write a small piece of code that delivers a kernel-mode AST to another process, where it will run code you have placed into system space. That code, in turn, will queue a user-mode AST to the process. Code to do this has been posted to the net at least once, but I'm afraid I don't have a copy. A good model for everything you need except perhaps allocating the system-space memory is the $FORCEX system service, which using this mechanism to force another process to execute a $EXIT. -- Jerry