IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 40424


Ignore:
Timestamp:
May 15, 2018, 8:56:30 AM (8 years ago)
Author:
eugene
Message:

change rule for JobID: continuously increment (abort at 231); use IDtype

Location:
trunk/Ohana/src/opihi
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/include/pantasks.h

    r36623 r40424  
    88
    99# define DEBUG 0
     10
     11typedef int IDtype;
    1012
    1113typedef enum {
     
    133135 
    134136typedef struct {
    135   int JobID;                            /* internal ID for job */
     137  IDtype JobID;                         /* internal ID for job */
    136138  int pid;                              /* external ID for job */
    137139
     
    204206void UpdateTaskTimerStats (Task *task, int mode, double dtime);
    205207
    206 int NextJobID (void);
     208IDtype NextJobID (void);
    207209void InitJobIDs (void);
    208210void FreeJobIDs (void);
    209 int FreeJobID (int ID);
    210211
    211212void InitJobs (void);
     
    213214
    214215Job *NextJob (void);
    215 Job *FindJob (int JobID);
     216Job *FindJob (IDtype JobID);
    216217void ListJobs (void);
    217218Job *CreateJob (Task *task);
     
    234235int SubmitControllerJob (Job *job);
    235236int DeleteControllerJob (Job *job);
    236 Job *FindControllerJob (int JobID);
     237Job *FindControllerJob (IDtype JobID);
    237238int StartController (void);
    238239int ControllerCommand (char *command, char *response, IOBuffer *buffer);
  • trunk/Ohana/src/opihi/pantasks/CheckController.c

    r39476 r40424  
    77
    88  char *p, *q;
    9   int i, Njobs, status, JobID;
     9  int i, Njobs, status;
     10  IDtype JobID;
    1011  Job *job;
    1112  IOBuffer buffer;
  • trunk/Ohana/src/opihi/pantasks/JobIDOps.c

    r40165 r40424  
    11# include "pantasks.h"
    22
    3 # define MAX_N_JOBS 50000
    4 static char *JobIDList;
    5 static int   JobIDPtr;
     3# define MAX_N_JOBS 0x80000000
     4
     5static IDtype JobIDMax = 0;
    66
    77void InitJobIDs () {
    8 
    9   JobIDPtr = 0;
    10   ALLOCATE (JobIDList, char, MAX_N_JOBS);
    11   bzero (JobIDList, MAX_N_JOBS*sizeof(char));
     8  JobIDMax = 0;
    129
    1310
    14 void FreeJobIDs () {
    15   free (JobIDList);
     11void FreeJobIDs () { }
     12
     13/* return next unique ID, recycle every MAX_N_JOBS */
     14IDtype NextJobID () {
     15
     16  JobIDMax ++;
     17  if (JobIDMax >= MAX_N_JOBS) {
     18    gprint (GP_ERR, "ERROR: too many jobs spawned: %d, aborting\n", JobIDMax);
     19    abort();
     20  }
     21
     22  return (JobIDMax);
    1623}
    1724
    18 /* return next unique ID, recycle every MAX_N_JOBS */
    19 int NextJobID () {
    20 
    21   int Ntry;
    22 
    23   JobIDPtr ++;
    24   if (JobIDPtr >= MAX_N_JOBS) JobIDPtr = 0;
    25 
    26   Ntry = 0;
    27   while (JobIDList[JobIDPtr]) {
    28     Ntry ++;
    29     JobIDPtr ++;
    30     if (JobIDPtr >= MAX_N_JOBS) JobIDPtr = 0;
    31     if (Ntry == MAX_N_JOBS) return (-1);
    32   }
    33   JobIDList[JobIDPtr] = TRUE;
    34   return (JobIDPtr);
    35 }
    36 
    37 int FreeJobID (int JobID) {
    38 
    39   if (JobID < 0) return (FALSE);
    40   if (JobID >= MAX_N_JOBS) return (FALSE);
    41 
    42   JobIDList[JobID] = FALSE;
    43   return (TRUE);
    44 }
     25/* I am going to rework the jobID so that it just grows.  no need to ever free them
     26   as an int, that allows 2^31 jobs (2e9 jobs) */
  • trunk/Ohana/src/opihi/pantasks/JobOps.c

    r38559 r40424  
    4141
    4242/* return job with given ID */
    43 Job *FindJob (int JobID) {
     43Job *FindJob (IDtype JobID) {
    4444
    4545  int i;
     
    5555
    5656/* return job with given controller Job ID */
    57 Job *FindControllerJob (int JobID) {
     57Job *FindControllerJob (IDtype JobID) {
    5858
    5959  int i;
     
    8282  gprint (GP_LOG, " Jobs in Pantasks Queue\n");
    8383  for (i = 0; i < Njobs; i++) {
    84     gprint (GP_LOG, " %4d  %6d: %-25s %10s %20s\n", Njobs, jobs[i][0].JobID, jobs[i][0].task[0].name, JobStateToString(jobs[i][0].state), jobs[i][0].argv[0]);
     84    gprint (GP_LOG, " %4d  %8d: %-25s %10s %20s\n", Njobs, jobs[i][0].JobID, jobs[i][0].task[0].name, JobStateToString(jobs[i][0].state), jobs[i][0].argv[0]);
    8585  }
    8686
     
    9797
    9898  job[0].JobID = NextJobID ();
     99
     100  // this should not happen; abort?
    99101  if (job[0].JobID < 0) {
    100102    free (job);
     
    165167  if (job == NULL) return;
    166168 
    167   FreeJobID (job[0].JobID);
    168 
    169169  for (i = 0; i < job[0].argc; i++) {
    170170    free (job[0].argv[i]);
  • trunk/Ohana/src/opihi/pantasks/delete.c

    r23530 r40424  
    44
    55  Job *job;
    6   int JobID;
     6  IDtype JobID;
    77
    88  if (argc != 3) goto usage;
  • trunk/Ohana/src/opihi/pantasks/kill.c

    r23530 r40424  
    44
    55  Job *job;
    6   int JobID;
     6  IDtype JobID;
    77
    88  if (argc < 2) {
     
    1010    return (FALSE);
    1111  }
    12   JobID = atoi (argv[1]);
     12  JobID = atoll (argv[1]);
    1313
    1414  JobTaskLock();
Note: See TracChangeset for help on using the changeset viewer.