IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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) */
Note: See TracChangeset for help on using the changeset viewer.