Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!rutgers!mcnc!ece-csc!ncrcae!ncr-sd!hp-sdd!hplabs!ucbvax!VENUS.YCC.YALE.EDU!leichter From: leichter@VENUS.YCC.YALE.EDU ("Jerry Leichter") Newsgroups: comp.os.vms Subject: re: run myprog/topcpu=? Clarification Message-ID: <8710171835.AA08060@ucbvax.Berkeley.EDU> Date: Sat, 17-Oct-87 11:33:00 EDT Article-I.D.: ucbvax.8710171835.AA08060 Posted: Sat Oct 17 11:33:00 1987 Date-Received: Sun, 18-Oct-87 12:37:45 EDT Sender: daemon@ucbvax.BERKELEY.EDU Reply-To: "Jerry Leichter" Organization: The ARPA Internet Lines: 51 ...I would like to be able to do is say $ RUN MYPROGRAM/TOPCPU=50:30 for example, so that myprogram will only run for 50 minutes, 30 seconds of cpu. The time does not have to be dead on, anything reasonable close would be ok.... As you note later, there is no built-in way to do this. The best approach, if you can modify the program, is to let it time itself: Use SYS$SETIMR to request an AST after some appropriate period of time. In the AST routine, check the accumulated runtime of the image (SYS$GETJPI will get it for you) and either re-schedule the AST or do a SYS$EXIT(). Using a fixed value of, say, 10 seconds for "appropriate" should work; the clever way is to wait for an amount of real time that equals the amount of further CPU time you want the image to have. The system calls involved here are fairly simple, but you can make things even easier on yourself by using VAX C - alarm() sets an alarm clock that you can catch with a signal handler; times() returns CPU time. You can use these even if your program is not written in C, though to use the signal stuff you would have to have a C main program. (Well, maybe not with the VMS V4.6 version of the C RTL.) Of course, the clean way to do this is to have a generic "establish time limit" procedure that you could put in a library and have all your code call. If you can't or don't want to modify your code, there's a simpler approach: Run the image in a subprocess, and monitor it from the main process. The following (untested!) draft of a command file should do it: $! $! Invoke as: @MRUN