286
285
* decoded value of time in seconds in the unsigned long integer.
289
static int gettime(pres, ret)
289
gettime(resource *pres, unsigned long *ret)
294
292
if (pres->rs_value.at_type != ATR_TYPE_LONG)
337
335
* Accepts a job pointer. Returns the sum of all cpu time
338
336
* consumed for all tasks executed by the job, in seconds.
340
static unsigned long cput_sum(pjob)
343
341
char *id = "cput_sum";
344
342
unsigned long cputime, addtime;
387
385
* Return TRUE if any process in the job is over limit for cputime usage.
389
static int overcput_proc(pjob, limit)
388
overcput_proc(job *pjob, unsigned long limit)
393
390
char *id = "overcput_proc";
394
391
unsigned long memsize;
486
483
error(char *string, int value)
491
487
assert(string != NULL);
492
488
assert(*string != '\0');
493
assert(value > PBSE_); /* minimum PBS error number */
494
assert(value <= PBSE_NOSYNCMSTR); /* maximum PBS error number */
495
assert(pbs_err_to_txt[i].err_no != 0);
499
if (pbs_err_to_txt[i].err_no == value)
502
while (pbs_err_to_txt[++i].err_no != 0);
504
assert(pbs_err_to_txt[i].err_txt != NULL);
506
message = *pbs_err_to_txt[i].err_txt;
490
message = pbse_to_txt(value);
508
492
assert(message != NULL);
510
493
assert(*message != '\0');
512
495
(void)fprintf(stderr, msg_momsetlim, string, message);
537
520
* existing limits. Cannot alter those set by setrlimit (kernel)
538
521
* because we are the wrong process.
540
int mom_set_limits(pjob, set_mode)
542
int set_mode; /* SET_LIMIT_SET or SET_LIMIT_ALTER */
526
int set_mode /* SET_LIMIT_SET or SET_LIMIT_ALTER */
544
529
char *id = "mom_set_limits";
573
558
if (strcmp(pname, "cput") == 0)
575
/* cpu time - check, if less than pcput use it */
576
retval = gettime(pres, &value);
560
if (igncput == FALSE)
562
/* cpu time - check, if less than pcput use it */
563
retval = gettime(pres, &value);
578
if (retval != PBSE_NONE)
579
return (error(pname, retval));
565
if (retval != PBSE_NONE)
566
return (error(pname, retval));
581
569
else if (strcmp(pname, "pcput") == 0)
583
/* process cpu time - set */
584
retval = gettime(pres, &value);
586
if (retval != PBSE_NONE)
587
return (error(pname, retval));
589
reslim.rlim_cur = reslim.rlim_max =
590
(unsigned long)((double)value / cputfactor);
592
if (setrlimit(RLIMIT_CPU, &reslim) < 0)
593
return (error("RLIMIT_CPU", PBSE_SYSTEM));
571
if (igncput == FALSE)
573
/* process cpu time - set */
574
retval = gettime(pres, &value);
576
if (retval != PBSE_NONE)
577
return (error(pname, retval));
579
reslim.rlim_cur = reslim.rlim_max =
580
(unsigned long)((double)value / cputfactor);
582
if (setrlimit(RLIMIT_CPU, &reslim) < 0)
583
return (error("RLIMIT_CPU", PBSE_SYSTEM));
595
586
else if (strcmp(pname, "file") == 0) /* set */
613
604
else if (strcmp(pname, "vmem") == 0) /* check */
615
retval = getsize(pres, &value);
617
if (retval != PBSE_NONE)
618
return (error(pname, retval));
620
if ((mem_limit == 0) || (value < mem_limit))
623
else if (strcmp(pname, "pvmem") == 0) /* set */
625
if (set_mode == SET_LIMIT_SET)
606
if (ignvmem == FALSE)
627
608
retval = getsize(pres, &value);
629
610
if (retval != PBSE_NONE)
630
611
return (error(pname, retval));
633
return (error(pname, PBSE_BADATVAL));
635
613
if ((mem_limit == 0) || (value < mem_limit))
636
614
mem_limit = value;
617
else if (strcmp(pname, "pvmem") == 0) /* set */
619
if (ignvmem == FALSE)
621
if (set_mode == SET_LIMIT_SET)
623
retval = getsize(pres, &value);
625
if (retval != PBSE_NONE)
626
return (error(pname, retval));
629
return (error(pname, PBSE_BADATVAL));
631
if ((mem_limit == 0) || (value < mem_limit))
639
636
else if (strcmp(pname, "walltime") == 0) /* Check */
641
638
retval = gettime(pres, &value);
805
802
assert(pname != NULL);
806
803
assert(*pname != '\0');
808
if (strcmp(pname, "cput") == 0)
805
if ((igncput == FALSE) && (strcmp(pname, "cput") == 0))
810
807
retval = gettime(pres, &value);
823
else if (strcmp(pname, "pcput") == 0)
820
else if ((igncput == FALSE) && (strcmp(pname, "pcput") == 0))
825
822
retval = gettime(pres, &value);
956
951
* Kill a task session.
957
952
* Call with the task pointer and a signal number.
959
int kill_task(ptask, sig, pg)
955
kill_task(task *ptask, int sig, int pg)
964
957
char *id = "kill_task";
1022
1014
* If abort is true, kill it too. Return -1 on error.
1025
int mach_checkpoint(ptask, file, abort)
1018
mach_checkpoint(task *ptask, char *file, int abort)