perkins@arc.CDN (Ernie Perkins) (10/17/87)
It's rather funny to see a comment on a entry that you have sent to info-vax, but have not yet received back from info-vax. (I guess our mailer is brain-dead?). Anyways .... What 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. The reason is simple ..... we have a number of programs which under certain conditions, spin their wheels forever. The programs generate enormous amounts of output, which should be immediately processes and then thrown away. Right now, the only reasonable ways are: 1) execute from a terminal, check with <CTRL>T . Terminate with <CTRL>Y. Run cleanup proceedure. 2) submit as a batch job with a time limit. Wait until it is finished, then run cleanup proceedure. Our system is often overloaded, so 1) is out to lunch. Besides, you can not walk away from it. 2) is o.k., but takes a minimum of two days to do (2 batch jobs). I rather do it in one go. The other reason is convenence. Without using <CTRL>T, or continually watching the cpu accumulate, you have no assurance that the program is running, is halted, or is going on forever. One of our technicians submitted a job that used more than 13 hours of cpu before it was noticed .... I realize that a /TOPCPU qualifier does not exist for a run command on VMS (it does on MTS). What I would like is a process/command/anything that will halt a routine automatically after a user specificed limit. It should not halt the process, thus the next command(s) could be executed. Ernie Perkins, ALBERTA RESEARCH COUNCIL, ORSD
WARNOCK@PRISM.CLEMSON.EDU (Todd Warnock) (10/17/87)
>Subject: RE: run myprog/topcpu=? Clarification >To: "perkins%arc.cdn" <@kl.sri.com,@relay.cs.net:perkins%arc.cdn@ubc.csnet> What about running the program as a batch job on a batch queue with a CPU limit ? We have different queues set up here with different CPU limits for just that purpose. Hope that helps. Todd Warnock VAX Systems Clemson University Clemson, South Carolina 29634-2803 ARPA: Warnock@Prism.Clemson.EDU BITnet: Warnock@Clemson
David.Gentzel@MORGUL.PSC.EDU (10/17/87)
>[...] >What 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. The reason is simple ..... we have a >number of programs which under certain conditions, spin their wheels >forever. >[...] One possibility is to create an account for the task you wish to perform and give it an appropriate CPU limit. When the limit is reached, the process is killed. Another possibility is to write a simple program which calls $CREPRC to create a process to run your task. $CREPRC can be given a CPU limit. Hope this helps. Internet: gentzel@morgul.psc.edu Dave Gentzel BITnet: gentzel@cpwpsca Pittsburgh Supercomputing Center
leichter@VENUS.YCC.YALE.EDU ("Jerry Leichter") (10/17/87)
...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 <time> <image> ... $! $! Where time is given if seconds. $! $ maxseconds = p1 !Be fancy here for, say, MM:SS times $ maxtime = maxseconds * 100 !(CPU time is measured in 10ms units $ spawn/nowait/process:"Watched_Pot" run 'p2' 'p3' 'p4' 'p5' 'p6' 'p7' 'p8' $loop: $ wait 00:00:10 !You can be fancy here $ cputime = f$getjpi("Watched_Pot","CPUTIM") $ if (cputime .lt. maxtime) then goto loop $ stop "Watched_Pot" This will forcibly clobber the process when it runs out of time. It's possible to do things like force it to exit (SYS$FORCEX call) - there's no standard DCL interface to that call, but interface programs have been written many times. Or you could just suspend the image, waiting for some human to look at it to decide if it should really be stopped or not. -- Jerry ------
mhg@MITRE-BEDFORD.ARPA (Mark H. Granoff) (10/19/87)
>... >What 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. >... How about setting the CPUTIME (in AUTHORIZE) for whatever account your programs are running on to 50 minutes and 30 seconds (using delta time)? I would assume that once a job has reached this limit, it is effectively logged out. +---------------------------------------------------------------------+ | Mark H. Granoff Member of the Technical Staff | +---------------------------------------------------------------------+ | USMAIL: The MITRE Corporation | ARPAnet: mhg @ mitre-bedford.ARPA | | Burlington Rd. | UUCP : linus!mbunix!mhg | | M/S B015 |-----------------------------------| | Bedford, MA 01730 | A T & T: (617) 271 - 7030 | +--------------------------- Disclaimer ------------------------------+ |The views expressed herein are my own and do not necessarily reflect | | those of my employer. | +---------------------------------------------------------------------+