~ubuntu-branches/ubuntu/precise/torque/precise-updates

« back to all changes in this revision

Viewing changes to src/resmom/sunos4/mom_mach.c

  • Committer: Bazaar Package Importer
  • Author(s): Dominique Belhachemi
  • Date: 2010-05-17 20:56:46 UTC
  • mto: This revision was merged to the branch mainline in revision 8.
  • Revision ID: james.westby@ubuntu.com-20100517205646-yjsoqs5r1s9xpnu9
Tags: upstream-2.4.8+dfsg
ImportĀ upstreamĀ versionĀ 2.4.8+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
137
137
#include "server_limits.h"
138
138
#include "attribute.h"
139
139
#include "resource.h"
140
 
#include "job.h"
 
140
#include "pbs_job.h"
141
141
#include "mom_mach.h"
142
142
#include "resmon.h"
143
143
#include "../rm_dep.h"
144
144
 
145
 
static char ident[] = "@(#) sun/$RCSfile$ $Revision: 2628 $";
 
145
static char ident[] = "@(#) sun/$RCSfile$ $Revision: 3151 $";
146
146
 
147
147
#ifndef TRUE
148
148
#define FALSE 0
162
162
extern double wallfactor;
163
163
/* wow, no ncpus - extern  long    system_ncpus; */
164
164
extern  int     ignwalltime;
 
165
extern  int     igncput;
165
166
extern  int     ignvmem;
 
167
extern  int     ignmem;
166
168
 
167
169
/*
168
170
** local functions
268
270
  /* No periodic functions. */
269
271
  }
270
272
 
271
 
extern struct pbs_err_to_txt pbs_err_to_txt[];
272
273
extern time_t   time_now;
273
274
 
274
275
/*
290
291
 *  sizeof(word) = sizeof(int)
291
292
 */
292
293
 
293
 
static int getsize(pres, ret)
294
 
resource  *pres;
295
 
unsigned long *ret;
 
294
static int
 
295
getsize(resource *pres, unsigned long *ret)
296
296
  {
297
297
  unsigned long value;
298
298
 
327
327
 * decoded value of time in seconds in the unsigned long integer.
328
328
 */
329
329
 
330
 
static int gettime(pres, ret)
331
 
resource  *pres;
332
 
unsigned long *ret;
 
330
static int
 
331
gettime(resource *pres, unsigned long *ret)
333
332
  {
334
333
 
335
334
  if (pres->rs_value.at_type != ATR_TYPE_LONG)
378
377
 * Accepts a session id.  Returns the sum of all cpu time consumed for all
379
378
 * tasks executed by the job, in seconds, adjusted by cputfactor.
380
379
 */
381
 
static unsigned long cput_sum(pjob)
382
 
job  *pjob;
 
380
static unsigned long
 
381
cput_sum(job *pjob)
383
382
  {
384
383
  char   *id = "cput_sum";
385
384
  int   i;
449
448
 * Accepts a job ID.  Returns the total number of bytes of address
450
449
 * space consumed by all current tasks within the job.
451
450
 */
452
 
static unsigned long mem_sum(pjob)
453
 
job  *pjob;
 
451
static unsigned long
 
452
mem_sum(job *pjob)
454
453
  {
455
454
  char  *id = "mem_sum";
456
455
  int  i;
481
480
/*
482
481
 * Internal session workingset size function.
483
482
 */
484
 
static unsigned long resi_sum(pjob)
485
 
job  *pjob;
 
483
static unsigned long
 
484
resi_sum(job *pjob)
486
485
  {
487
486
  char  *id = "resi_sum";
488
487
  int  i;
514
513
/*
515
514
 * Return TRUE if any task in the job is over limit for memory usage.
516
515
 */
517
 
static int overmem_proc(pjob, limit)
518
 
job   *pjob;
519
 
unsigned long limit;
 
516
static int
 
517
overmem_proc(job *pjob, unsigned long limit)
520
518
  {
521
519
  int   i;
522
520
 
546
544
int
547
545
error(char *string, int value)
548
546
  {
549
 
  int  i = 0;
550
547
  char  *message;
551
548
 
552
549
  assert(string != NULL);
553
550
  assert(*string != '\0');
554
 
  assert(value > PBSE_);   /* minimum PBS error number */
555
 
  assert(value <= PBSE_NOSYNCMSTR); /* maximum PBS error number */
556
 
  assert(pbs_err_to_txt[i].err_no != 0);
557
 
 
558
 
  do
559
 
    {
560
 
    if (pbs_err_to_txt[i].err_no == value)
561
 
      break;
562
 
    }
563
 
  while (pbs_err_to_txt[++i].err_no != 0);
564
 
 
565
 
  assert(pbs_err_to_txt[i].err_txt != NULL);
566
 
 
567
 
  message = *pbs_err_to_txt[i].err_txt;
 
551
 
 
552
  message = pbse_to_txt(value);
568
553
 
569
554
  assert(message != NULL);
570
 
 
571
555
  assert(*message != '\0');
572
556
 
573
557
  (void)fprintf(stderr, msg_momsetlim, string, message);
598
582
 * existing limits.  Cannot alter those set by setrlimit (kernel)
599
583
 * because we are the wrong process.
600
584
 */
601
 
int mom_set_limits(pjob, set_mode)
602
 
job   *pjob;
603
 
int    set_mode; /* SET_LIMIT_SET or SET_LIMIT_ALTER */
 
585
int
 
586
mom_set_limits(
 
587
  job *pjob,
 
588
  int set_mode /* SET_LIMIT_SET or SET_LIMIT_ALTER */
 
589
)
604
590
  {
605
591
  char  *id = "mom_set_limits";
606
592
  char  *pname;
632
618
 
633
619
    if (strcmp(pname, "cput") == 0)   /* cpu time - check */
634
620
      {
635
 
      retval = gettime(pres, &value);
 
621
      if (igncput == FALSE)
 
622
        {
 
623
        retval = gettime(pres, &value);
636
624
 
637
 
      if (retval != PBSE_NONE)
638
 
        return (error(pname, retval));
 
625
        if (retval != PBSE_NONE)
 
626
          return (error(pname, retval));
 
627
        }
639
628
      }
640
629
    else if (strcmp(pname, "pcput") == 0)
641
630
      {
642
 
      /* process cpu time - set */
643
 
      if (set_mode == SET_LIMIT_SET)
 
631
      if (igncput == FALSE)
644
632
        {
645
 
        retval = gettime(pres, &value);
646
 
 
647
 
        if (retval != PBSE_NONE)
648
 
          return (error(pname, retval));
649
 
 
650
 
        assert(value <= INT_MAX);
651
 
 
652
 
        reslim.rlim_cur = reslim.rlim_max =
653
 
                            (unsigned long)((double)value / cputfactor);
654
 
 
655
 
        if (setrlimit(RLIMIT_CPU, &reslim) < 0)
656
 
          return (error("RLIMIT_CPU", PBSE_SYSTEM));
 
633
        /* process cpu time - set */
 
634
        if (set_mode == SET_LIMIT_SET)
 
635
          {
 
636
          retval = gettime(pres, &value);
 
637
 
 
638
          if (retval != PBSE_NONE)
 
639
            return (error(pname, retval));
 
640
 
 
641
          assert(value <= INT_MAX);
 
642
 
 
643
          reslim.rlim_cur = reslim.rlim_max =
 
644
            (unsigned long)((double)value / cputfactor);
 
645
 
 
646
          if (setrlimit(RLIMIT_CPU, &reslim) < 0)
 
647
            return (error("RLIMIT_CPU", PBSE_SYSTEM));
 
648
          }
657
649
        }
658
650
      }
659
651
    else if (strcmp(pname, "file") == 0)   /* set */
676
668
      }
677
669
    else if (strcmp(pname, "vmem") == 0)   /* check */
678
670
      {
679
 
      retval = getsize(pres, &value);
 
671
      if (ignvmem == FALSE)
 
672
        {
 
673
        retval = getsize(pres, &value);
680
674
 
681
 
      if (retval != PBSE_NONE)
682
 
        return (error(pname, retval));
 
675
        if (retval != PBSE_NONE)
 
676
          return (error(pname, retval));
 
677
        }
683
678
      }
684
679
    else if (strcmp(pname, "pvmem") == 0)   /* set */
685
680
      {
686
 
      if (set_mode == SET_LIMIT_SET)
 
681
      if (ignvmem == FALSE)
687
682
        {
688
 
        retval = getsize(pres, &value);
689
 
 
690
 
        if (retval != PBSE_NONE)
691
 
          return (error(pname, retval));
692
 
 
693
 
        if (value > INT_MAX)
694
 
          return (error(pname, PBSE_BADATVAL));
695
 
 
696
 
        reslim.rlim_cur = reslim.rlim_max = value;
697
 
 
698
 
        if ((ignvmem == 0) && (setrlimit(RLIMIT_DATA, &reslim) < 0))
699
 
          return (error("RLIMIT_DATA", PBSE_SYSTEM));
700
 
 
701
 
        if ((ignvmem == 0) && (setrlimit(RLIMIT_STACK, &reslim) < 0))
702
 
          return (error("RLIMIT_STACK", PBSE_SYSTEM));
 
683
        if (set_mode == SET_LIMIT_SET)
 
684
          {
 
685
          retval = getsize(pres, &value);
 
686
 
 
687
          if (retval != PBSE_NONE)
 
688
            return (error(pname, retval));
 
689
 
 
690
          if (value > INT_MAX)
 
691
            return (error(pname, PBSE_BADATVAL));
 
692
 
 
693
          reslim.rlim_cur = reslim.rlim_max = value;
 
694
 
 
695
          if ((ignvmem == 0) && (setrlimit(RLIMIT_DATA, &reslim) < 0))
 
696
            return (error("RLIMIT_DATA", PBSE_SYSTEM));
 
697
 
 
698
          if ((ignvmem == 0) && (setrlimit(RLIMIT_STACK, &reslim) < 0))
 
699
            return (error("RLIMIT_STACK", PBSE_SYSTEM));
 
700
          }
703
701
        }
704
702
      }
705
703
    else if (strcmp(pname, "mem") == 0)    /* ignore */
707
705
      }
708
706
    else if (strcmp(pname, "pmem") == 0)   /* set */
709
707
      {
710
 
      if (set_mode == SET_LIMIT_SET)
 
708
      if (ignmem == FALSE)
711
709
        {
712
 
        retval = getsize(pres, &value);
713
 
 
714
 
        if (retval != PBSE_NONE)
715
 
          return (error(pname, retval));
716
 
 
717
 
        reslim.rlim_cur = reslim.rlim_max = value;
718
 
 
719
 
        if (setrlimit(RLIMIT_RSS, &reslim) < 0)
720
 
          return (error("RLIMIT_RSS", PBSE_SYSTEM));
 
710
        if (set_mode == SET_LIMIT_SET)
 
711
          {
 
712
          retval = getsize(pres, &value);
 
713
 
 
714
          if (retval != PBSE_NONE)
 
715
            return (error(pname, retval));
 
716
 
 
717
          reslim.rlim_cur = reslim.rlim_max = value;
 
718
  
 
719
          if (setrlimit(RLIMIT_RSS, &reslim) < 0)
 
720
            return (error("RLIMIT_RSS", PBSE_SYSTEM));
 
721
          }
721
722
        }
722
723
      }
723
724
    else if (strcmp(pname, "walltime") == 0)   /* Check */
756
757
 * polling is done using the mom_over_limit machine-dependent function.
757
758
 */
758
759
 
759
 
int mom_do_poll(pjob)
760
 
job   *pjob;
 
760
int
 
761
mom_do_poll(job *pjob)
761
762
  {
762
763
  char  *id = "mom_do_poll";
763
764
  char  *pname;
944
945
 * Otherwise, return FALSE.
945
946
 */
946
947
 
947
 
int mom_over_limit(pjob)
948
 
job   *pjob;
 
948
int
 
949
mom_over_limit(job *pjob)
949
950
  {
950
951
  char  *id = "mom_over_limit";
951
952
  char  *pname;
967
968
    assert(pname != NULL);
968
969
    assert(*pname != '\0');
969
970
 
970
 
    if (strcmp(pname, "cput") == 0)
 
971
    if ((igncput == FALSE) && (strcmp(pname, "cput") == 0))
971
972
      {
972
973
      retval = gettime(pres, &value);
973
974
 
1012
1013
        return (TRUE);
1013
1014
        }
1014
1015
      }
1015
 
    else if (strcmp(pname, "walltime") == 0)
 
1016
    else if (ignwalltime == 0 && strcmp(pname, "walltime") == 0)
1016
1017
      {
1017
1018
      if ((pjob->ji_qs.ji_svrflags & JOB_SVFLG_HERE) == 0)
1018
1019
        continue;
1029
1030
        sprintf(log_buffer,
1030
1031
                "walltime %d exceeded limit %d",
1031
1032
                num, value);
1032
 
 
1033
 
        if (ignwalltime == 0)
1034
 
          return (TRUE);
 
1033
        return (TRUE);
1035
1034
        }
1036
1035
      }
1037
1036
    }
1048
1047
 *
1049
1048
 * Assumes that the session ID attribute has already been set.
1050
1049
 */
1051
 
int mom_set_use(pjob)
1052
 
job  *pjob;
 
1050
int
 
1051
mom_set_use(job *pjob)
1053
1052
  {
1054
1053
  char  *id = "mom_set_use";
1055
1054
  resource *pres;
1143
1142
 * Kill a job task.
1144
1143
 * Call with the job and a signal number.
1145
1144
 */
1146
 
int kill_task(ptask, sig, pg)
1147
 
task *ptask;
1148
 
int  sig;
1149
 
int         pg;
 
1145
int
 
1146
kill_task(task *ptask, int sig, int pg)
1150
1147
  {
1151
1148
  char *id = "kill_task";
1152
1149
  int ct = 0;
1208
1205
  }
1209
1206
 
1210
1207
/*
1211
 
 * mom_does_chkpnt - return 1 if mom supports checkpoint
1212
 
 *       0 if not
 
1208
 * mom_does_checkpoint
1213
1209
 */
1214
1210
 
1215
1211
int
1216
 
mom_does_chkpnt(void)
 
1212
mom_does_checkpoint(void)
1217
1213
  {
1218
 
  return (0);
 
1214
  return(CST_NONE);
1219
1215
  }
1220
1216
 
1221
1217
/*
1224
1220
 * If abort is true, kill it too.
1225
1221
 */
1226
1222
 
1227
 
int mach_checkpoint(ptask, file, abort)
1228
 
task *ptask;
1229
 
char *file;
1230
 
int  abort;
 
1223
int
 
1224
mach_checkpoint(task *ptask, char *file, int abort)
1231
1225
  {
1232
1226
  return (-1);
1233
1227
  }
1238
1232
 * Return -1 on error or sid if okay.
1239
1233
 */
1240
1234
 
1241
 
long mach_restart(ptask, file)
1242
 
task *ptask;
1243
 
char *file;
 
1235
long
 
1236
mach_restart(task *ptask, char *file)
1244
1237
  {
1245
1238
  return (-1);
1246
1239
  }