IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 32584


Ignore:
Timestamp:
Oct 28, 2011, 6:38:09 AM (15 years ago)
Author:
eugene
Message:

adding nice capability to pantasks / pcontrol / pclient

Location:
branches/eam_branches/ipp-20110906/Ohana/src/opihi
Files:
1 added
10 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20110906/Ohana/src/opihi/include/pantasks.h

    r31667 r32584  
    115115
    116116  int active;
     117  int priority;
    117118
    118119} Task;
     
    159160
    160161  JobMode     mode;                     /* local or controller? */
     162  int     priority;
    161163  char   *realhost;
    162164
  • branches/eam_branches/ipp-20110906/Ohana/src/opihi/include/pcontrol.h

    r32568 r32584  
    119119  int          exit_status;
    120120  int          Reset;
     121  int          priority;
    121122  JobMode      mode;
    122123  JobStat      state;
     
    313314Job   *PullJobByID (IDtype JobID, int *StackID);
    314315Job   *PullJobFromStackByID (int StackID, int ID);
    315 IDtype AddJob (char *hostname, JobMode mode, int timeout, int argc, char **argv, int Nxhosts, char **xhosts);
     316IDtype AddJob (char *hostname, JobMode mode, int timeout, int priority, int argc, char **argv, int Nxhosts, char **xhosts);
    316317void   DelJob (Job *job);
    317318Host  *UnlinkJobAndHost (Job *job);
  • branches/eam_branches/ipp-20110906/Ohana/src/opihi/pantasks/ControllerOps.c

    r27491 r32584  
    258258      sprintf (cmd, "job -host %s", job[0].task[0].host);
    259259    }
     260  }
     261 
     262  if (job[0].priority) {
     263    char tmp[64];
     264    snprintf (tmp, 64, " -nice %d", job[0].priority);
     265    strcat (cmd, tmp);
    260266  }
    261267
  • branches/eam_branches/ipp-20110906/Ohana/src/opihi/pantasks/JobOps.c

    r31666 r32584  
    107107    job[0].mode = JOB_CONTROLLER;
    108108  }
     109  job[0].priority = task[0].priority;
    109110
    110111  /* we need our own copy of task[0].argv argc is the number of valid args, like the usual command line.  we
  • branches/eam_branches/ipp-20110906/Ohana/src/opihi/pantasks/LocalJob.c

    r23530 r32584  
    161161  if (VerboseMode()) gprint (GP_ERR, "local job launched\n");
    162162
     163  /* set nice level for the child process -- maybe I should not exit here... */
     164  if (job[0].priority) {
     165      status = setpriority (PRIO_PROCESS, pid, job[0].priority);
     166      if (status == -1) {
     167          gprint (GP_ERR, "error setting priority\n");
     168          perror ("setpriority: ");
     169          exit (2);
     170      }
     171  }
     172
    163173  /* close the other ends of the pipes */
    164174  close (stdout_fd[1]); stdout_fd[1] = 0;
  • branches/eam_branches/ipp-20110906/Ohana/src/opihi/pantasks/TaskOps.c

    r31856 r32584  
    487487
    488488  NewTask[0].active = TRUE;
     489  NewTask[0].priority = 0;
    489490  return (NewTask);
    490491}
  • branches/eam_branches/ipp-20110906/Ohana/src/opihi/pclient/job.c

    r20047 r32584  
    33int job (int argc, char **argv) {
    44
    5   int i, pid, status;
     5  int i, pid, status, priority;
    66  char **targv;
     7
     8  priority = 0;
     9  if ((N = get_argument (argc, argv, "-nice"))) {
     10    remove_argument (N, &argc, argv);
     11    priority = atoi (argv[N]);
     12    remove_argument (N, &argc, argv);
     13  }
    714
    815  if (argc < 2) {
     
    5461  }
    5562
     63  /* set nice level for the child process */
     64  if (priority) {
     65      status = setpriority (PRIO_PROCESS, pid, priority);
     66      if (status == -1) {
     67          gprint (GP_ERR, "error setting priority\n");
     68          perror ("setpriority: ");
     69          exit (2);
     70      }
     71  }
     72
    5673  /* free temporary arg list */
    5774  for (i = 0; i < argc - 1; i++) {
  • branches/eam_branches/ipp-20110906/Ohana/src/opihi/pcontrol/JobOps.c

    r32568 r32584  
    195195}
    196196
    197 IDtype AddJob (char *hostname, JobMode mode, int timeout, int argc, char **argv, int Nxhosts, char **xhosts) {
     197IDtype AddJob (char *hostname, JobMode mode, int timeout, int priority, int argc, char **argv, int Nxhosts, char **xhosts) {
    198198
    199199  int JobID;
     
    220220
    221221  job[0].mode     = mode;
     222  job[0].priority = priority;
    222223
    223224  job[0].state = 0;
  • branches/eam_branches/ipp-20110906/Ohana/src/opihi/pcontrol/StartJob.c

    r28317 r32584  
    2525  bzero (line, Nline);
    2626  strcpy (line, "job");
     27  if (job[0].priority) {
     28    char tmp[64];
     29    snprintf (tmp, 64, " -nice %d", job[0].priority);
     30    strcat (line, tmp);
     31  }
    2732  for (i = 0; i < job[0].argc; i++) {
    2833    strcat (line, " ");
  • branches/eam_branches/ipp-20110906/Ohana/src/opihi/pcontrol/job.c

    r29558 r32584  
    55  char *Host = NULL;
    66  char **targv = NULL;
    7   int i, N, Mode, targc, Timeout;
     7  int i, N, Mode, targc, Timeout, priority;
    88  IDtype JobID;
    99  char **xhosts = NULL;
     
    4343  }
    4444
     45  priority = 0;
     46  if ((N = get_argument (argc, argv, "-nice"))) {
     47    remove_argument (N, &argc, argv);
     48    priority = atoi (argv[N]);
     49    remove_argument (N, &argc, argv);
     50  }
     51
    4552  xhosts = NULL;
    4653  Nxhosts = 0;
     
    7279
    7380  // a JobID < 0 mean the job was not accepted
    74   JobID = AddJob (Host, Mode, Timeout, targc, targv, Nxhosts, xhosts);
     81  JobID = AddJob (Host, Mode, Timeout, priority, targc, targv, Nxhosts, xhosts);
    7582  gprint (GP_LOG, "JobID: %d\n", (int) JobID);
    7683  return (TRUE);
Note: See TracChangeset for help on using the changeset viewer.