abe@mace.cc.purdue.edu (Vic Abell) (02/26/91)
The attached test program works under BSD 4.3-Tahoe, Ultrix 2.2, SunOS 4.0.3, NeXTOS 1.0 and DYNIX 3.0.12. It doesn't work under AIX 3.1 (3003). What else do I need do to limit CPU time? Csh's "limit cputime nnn" command doesn't seem to work, either. Vic Abell <abe@mace.cc.purdue.edu> #include <stdio.h> #include <signal.h> #include <sys/resource.h> #define TIMEOUT 20 #define NEWLIM 1 void cpulim() { (void) fprintf(stderr, "CPU time limit signal received\n"); exit(0); } void timeout() { (void) fprintf(stderr, "%d second alarm rang\n", TIMEOUT); exit(1); } main() { struct rlimit r; if (getrlimit(RLIMIT_CPU, &r) != 0) { perror("getrlimit(RLIMIT_CPU)"); exit(1); } (void) fprintf(stderr, "current (soft) RLIMIT_CPU = %d\n", r.rlim_cur); r.rlim_cur = NEWLIM; if (setrlimit(RLIMIT_CPU, &r) != 0) { perror("setrlimit(RLIMIT_CPU)"); exit(1); } (void) fprintf(stderr, "new (soft) RLIMIT_CPU = %d\n", NEWLIM); (void) signal (SIGALRM, timeout); (void) signal(SIGXCPU, cpulim); alarm(TIMEOUT); for(;;) ; /* NOTREACHED */ }
scott@prism.gatech.EDU (Scott Holt) (02/27/91)
In article <6893@mace.cc.purdue.edu> abe@mace.cc.purdue.edu (Vic Abell) writes: >The attached test program works under BSD 4.3-Tahoe, Ultrix 2.2, SunOS >4.0.3, NeXTOS 1.0 and DYNIX 3.0.12. It doesn't work under AIX 3.1 >(3003). What else do I need do to limit CPU time? > >Csh's "limit cputime nnn" command doesn't seem to work, either. > >Vic Abell <abe@mace.cc.purdue.edu> In short - no. SIGXCPU does not work. Despite documentation to the contrary (see info pages for set/getrlimit), A SIGXCPU is not sent to a process upon reaching its soft CPU time limit. Nothing is sent at all - there is no CPU time limit under AIX 3. I reported this problem to IBM and their response was that it was a documentation error. They refered me to the info entry for the Limits file - which states that the CPU time limit in the file is not used. Their fix - change the documentation to setrlimit. In all fairness to the software defects group - they were actually quite helpfull...but what can they do other than collect the details and refer the problem to the developers. They suggested the route I am going to take, put in a request for a design change through our local reps. Perhaps you should do the same. For us, the ability to have a CPU time limit is crucial - we plan to implement a processor farm of sorts managed by a batch management system such as NQS. CPU time limits (as well as memory limits and others that AIX does support) are vitally important to such a system - especially when batch queue priorities and job scheduling are to be based on resource demands. If we can't have a reasonable method to enforce all resource limits, then we cannot use the machine for this project. - Scott -- This is my signature. There are many like it, but this one is mine. Scott Holt Internet: scott@prism.gatech.edu Georgia Tech UUCP: ..!gatech!prism!scott Office of Information Technology, Technical Services
abe@mace.cc.purdue.edu (Vic Abell) (02/27/91)
In article <22867@hydra.gatech.EDU> scott@prism.gatech.EDU (Scott Holt) writes: > >In short - no. SIGXCPU does not work. > . . . >For us, the ability to have a CPU time limit is crucial - we plan to implement >a processor farm of sorts managed by a batch management system such as NQS. That's why I asked the question. We're near the end of the single-machine NQS port and looking at production and network scheduling issues. Another AIX 3.1 deficiency that affects NQS is the lack of support for csh's /etc/.login environment support. The /etc/environment support is login- specific, /etc/profile only supports sh and ksh, so NQS has no ready way to influence the environment of those who use csh under NQS - e. g., setting the TZ environment variable. It will be interesting to see what IBM's answer will be to that defect. :-) Vic Abell