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

« back to all changes in this revision

Viewing changes to src/resmom/hpux10/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:
107
107
#include "server_limits.h"
108
108
#include "attribute.h"
109
109
#include "resource.h"
110
 
#include "job.h"
 
110
#include "pbs_job.h"
111
111
#include "log.h"
112
112
#include "mom_mach.h"
113
113
#include "resmon.h"
137
137
**  valid_user is user name valid..
138
138
*/
139
139
 
140
 
static char ident[] = "@(#) hpux10/$RCSfile$ $Revision: 2628 $";
 
140
static char ident[] = "@(#) hpux10/$RCSfile$ $Revision: 3151 $";
141
141
 
142
142
#ifndef TRUE
143
143
#define FALSE 0
161
161
extern double wallfactor;
162
162
extern  long    system_ncpus;
163
163
extern  int     ignwalltime;
 
164
extern  int     igncput;
164
165
extern  int     ignvmem;
165
166
 
166
167
/*
187
188
 
188
189
#define TBL_INC 20
189
190
 
190
 
extern struct pbs_err_to_txt pbs_err_to_txt[];
191
191
extern time_t   time_now;
192
192
 
193
193
extern char extra_parm[];
249
249
 *  sizeof(word) = sizeof(int)
250
250
 */
251
251
 
252
 
static int getsize(pres, ret)
253
 
resource  *pres;
254
 
unsigned long *ret;
 
252
static int
 
253
getsize(resource *pres, unsigned long *ret)
255
254
  {
256
255
  unsigned long value;
257
256
 
286
285
 * decoded value of time in seconds in the unsigned long integer.
287
286
 */
288
287
 
289
 
static int gettime(pres, ret)
290
 
resource  *pres;
291
 
unsigned long *ret;
 
288
static int
 
289
gettime(resource *pres, unsigned long *ret)
292
290
  {
293
291
 
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.
339
337
 */
340
 
static unsigned long cput_sum(pjob)
341
 
job   *pjob;
 
338
static unsigned long
 
339
cput_sum(job *pjob)
342
340
  {
343
341
  char   *id = "cput_sum";
344
342
  unsigned long  cputime, addtime;
386
384
/*
387
385
 * Return TRUE if any process in the job is over limit for cputime usage.
388
386
 */
389
 
static int overcput_proc(pjob, limit)
390
 
job   *pjob;
391
 
unsigned long limit;
 
387
static int
 
388
overcput_proc(job *pjob, unsigned long limit)
392
389
  {
393
390
  char          *id = "overcput_proc";
394
391
  unsigned long         memsize;
426
423
 * Returns the total number of bytes of address
427
424
 * space consumed by all current tasks within the session.
428
425
 */
429
 
static unsigned long mem_sum(pjob)
430
 
job   *pjob;
 
426
static unsigned long
 
427
mem_sum(job *pjob)
431
428
  {
432
429
  char          *id = "mem_sum";
433
430
  unsigned long         memsize;
453
450
/*
454
451
 * Internal session mem (workingset) size function.
455
452
 */
456
 
static unsigned long resi_sum(pjob)
457
 
job   *pjob;
 
453
static unsigned long
 
454
resi_sum(job *pjob)
458
455
  {
459
456
  char          *id = "resi_sum";
460
457
  unsigned long         resisize;
485
482
int
486
483
error(char *string, int value)
487
484
  {
488
 
  int  i = 0;
489
485
  char  *message;
490
486
 
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);
496
 
 
497
 
  do
498
 
    {
499
 
    if (pbs_err_to_txt[i].err_no == value)
500
 
      break;
501
 
    }
502
 
  while (pbs_err_to_txt[++i].err_no != 0);
503
 
 
504
 
  assert(pbs_err_to_txt[i].err_txt != NULL);
505
 
 
506
 
  message = *pbs_err_to_txt[i].err_txt;
 
489
 
 
490
  message = pbse_to_txt(value);
507
491
 
508
492
  assert(message != NULL);
509
 
 
510
493
  assert(*message != '\0');
511
494
 
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.
539
522
 */
540
 
int mom_set_limits(pjob, set_mode)
541
 
job   *pjob;
542
 
int    set_mode; /* SET_LIMIT_SET or SET_LIMIT_ALTER */
 
523
int
 
524
mom_set_limits(
 
525
  job *pjob,
 
526
  int set_mode /* SET_LIMIT_SET or SET_LIMIT_ALTER */
 
527
)
543
528
  {
544
529
  char  *id = "mom_set_limits";
545
530
  char  *pname;
572
557
 
573
558
    if (strcmp(pname, "cput") == 0)
574
559
      {
575
 
      /* cpu time - check, if less than pcput use it */
576
 
      retval = gettime(pres, &value);
 
560
      if (igncput == FALSE)
 
561
        {
 
562
        /* cpu time - check, if less than pcput use it */
 
563
        retval = gettime(pres, &value);
577
564
 
578
 
      if (retval != PBSE_NONE)
579
 
        return (error(pname, retval));
 
565
        if (retval != PBSE_NONE)
 
566
          return (error(pname, retval));
 
567
        }
580
568
      }
581
569
    else if (strcmp(pname, "pcput") == 0)
582
570
      {
583
 
      /* process cpu time - set */
584
 
      retval = gettime(pres, &value);
585
 
 
586
 
      if (retval != PBSE_NONE)
587
 
        return (error(pname, retval));
588
 
 
589
 
      reslim.rlim_cur = reslim.rlim_max =
590
 
                          (unsigned long)((double)value / cputfactor);
591
 
 
592
 
      if (setrlimit(RLIMIT_CPU, &reslim) < 0)
593
 
        return (error("RLIMIT_CPU", PBSE_SYSTEM));
 
571
      if (igncput == FALSE)
 
572
        {
 
573
        /* process cpu time - set */
 
574
        retval = gettime(pres, &value);
 
575
 
 
576
        if (retval != PBSE_NONE)
 
577
          return (error(pname, retval));
 
578
 
 
579
        reslim.rlim_cur = reslim.rlim_max =
 
580
          (unsigned long)((double)value / cputfactor);
 
581
 
 
582
        if (setrlimit(RLIMIT_CPU, &reslim) < 0)
 
583
          return (error("RLIMIT_CPU", PBSE_SYSTEM));
 
584
        }
594
585
      }
595
586
    else if (strcmp(pname, "file") == 0)   /* set */
596
587
      {
612
603
      }
613
604
    else if (strcmp(pname, "vmem") == 0)   /* check */
614
605
      {
615
 
      retval = getsize(pres, &value);
616
 
 
617
 
      if (retval != PBSE_NONE)
618
 
        return (error(pname, retval));
619
 
 
620
 
      if ((mem_limit == 0) || (value < mem_limit))
621
 
        mem_limit = value;
622
 
      }
623
 
    else if (strcmp(pname, "pvmem") == 0)   /* set */
624
 
      {
625
 
      if (set_mode == SET_LIMIT_SET)
 
606
      if (ignvmem == FALSE)
626
607
        {
627
608
        retval = getsize(pres, &value);
628
609
 
629
610
        if (retval != PBSE_NONE)
630
611
          return (error(pname, retval));
631
612
 
632
 
        if (value > INT_MAX)
633
 
          return (error(pname, PBSE_BADATVAL));
634
 
 
635
613
        if ((mem_limit == 0) || (value < mem_limit))
636
614
          mem_limit = value;
637
615
        }
638
616
      }
 
617
    else if (strcmp(pname, "pvmem") == 0)   /* set */
 
618
      {
 
619
      if (ignvmem == FALSE)
 
620
        {
 
621
        if (set_mode == SET_LIMIT_SET)
 
622
          {
 
623
          retval = getsize(pres, &value);
 
624
 
 
625
          if (retval != PBSE_NONE)
 
626
            return (error(pname, retval));
 
627
 
 
628
          if (value > INT_MAX)
 
629
            return (error(pname, PBSE_BADATVAL));
 
630
 
 
631
          if ((mem_limit == 0) || (value < mem_limit))
 
632
            mem_limit = value;
 
633
          }
 
634
        }
 
635
      }
639
636
    else if (strcmp(pname, "walltime") == 0)   /* Check */
640
637
      {
641
638
      retval = gettime(pres, &value);
684
681
 * polling is done using the mom_over_limit machine-dependent function.
685
682
 */
686
683
 
687
 
int mom_do_poll(pjob)
688
 
job   *pjob;
 
684
int
 
685
mom_do_poll(job *pjob)
689
686
  {
690
687
  char  *id = "mom_do_poll";
691
688
  char  *pname;
782
779
 * Otherwise, return FALSE.
783
780
 */
784
781
 
785
 
int mom_over_limit(pjob)
786
 
job   *pjob;
 
782
int
 
783
mom_over_limit(job *pjob)
787
784
  {
788
785
  char  *id = "mom_over_limit";
789
786
  char  *pname;
805
802
    assert(pname != NULL);
806
803
    assert(*pname != '\0');
807
804
 
808
 
    if (strcmp(pname, "cput") == 0)
 
805
    if ((igncput == FALSE) && (strcmp(pname, "cput") == 0))
809
806
      {
810
807
      retval = gettime(pres, &value);
811
808
 
820
817
        return (TRUE);
821
818
        }
822
819
      }
823
 
    else if (strcmp(pname, "pcput") == 0)
 
820
    else if ((igncput == FALSE) && (strcmp(pname, "pcput") == 0))
824
821
      {
825
822
      retval = gettime(pres, &value);
826
823
 
850
847
        return (TRUE);
851
848
        }
852
849
      }
853
 
    else if (strcmp(pname, "walltime") == 0)
 
850
    else if (ignwalltime == 0 && strcmp(pname, "walltime") == 0)
854
851
      {
855
852
      if ((pjob->ji_qs.ji_svrflags & JOB_SVFLG_HERE) == 0)
856
853
        continue;
867
864
        sprintf(log_buffer,
868
865
                "walltime %d exceeded limit %d",
869
866
                num, value);
870
 
 
871
 
        if (ignwalltime == 0)
872
 
          return (TRUE);
 
867
        return (TRUE);
873
868
        }
874
869
      }
875
870
    }
886
881
 *
887
882
 * Assumes that the session ID attribute has already been set.
888
883
 */
889
 
int mom_set_use(pjob)
890
 
job   *pjob;
 
884
int
 
885
mom_set_use(job *pjob)
891
886
  {
892
887
  char   *id = "mom_set_use";
893
888
  resource  *pres;
956
951
 * Kill a task session.
957
952
 * Call with the task pointer and a signal number.
958
953
 */
959
 
int kill_task(ptask, sig, pg)
960
 
task *ptask;
961
 
int   sig;
962
 
int         pg;
 
954
int
 
955
kill_task(task *ptask, int sig, int pg)
963
956
  {
964
957
  char          *id = "kill_task";
965
958
  int          ct = 0;
1006
999
  }
1007
1000
 
1008
1001
/*
1009
 
 * mom_does_chkpnt - return 1 if mom supports checkpoint
1010
 
 *       0 if not
 
1002
 * mom_does_checkpoint
1011
1003
 */
1012
1004
 
1013
1005
int
1014
 
mom_does_chkpnt(void)
 
1006
mom_does_checkpoint(void)
1015
1007
  {
1016
 
  return (0);
 
1008
  return(CST_NONE);
1017
1009
  }
1018
1010
 
1019
1011
/*
1022
1014
 * If abort is true, kill it too.  Return -1 on error.
1023
1015
 */
1024
1016
 
1025
 
int mach_checkpoint(ptask, file, abort)
1026
 
task *ptask;
1027
 
char *file;
1028
 
int  abort;
 
1017
int
 
1018
mach_checkpoint(task *ptask, char *file, int abort)
1029
1019
  {
1030
1020
  return (-1);
1031
1021
  }
1034
1024
 * Restart the job from the checkpoint file.
1035
1025
 */
1036
1026
 
1037
 
long mach_restart(ptask, file)
1038
 
task *ptask;
1039
 
char *file;
 
1027
long
 
1028
mach_restart(task *ptask, char *file)
1040
1029
  {
1041
1030
  return (-1);
1042
1031
  }