Changeset 40424 for trunk/Ohana/src/opihi/pantasks/JobIDOps.c
- Timestamp:
- May 15, 2018, 8:56:30 AM (8 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/pantasks/JobIDOps.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/pantasks/JobIDOps.c
r40165 r40424 1 1 # include "pantasks.h" 2 2 3 # define MAX_N_JOBS 500004 static char *JobIDList; 5 static int JobIDPtr;3 # define MAX_N_JOBS 0x80000000 4 5 static IDtype JobIDMax = 0; 6 6 7 7 void InitJobIDs () { 8 9 JobIDPtr = 0; 10 ALLOCATE (JobIDList, char, MAX_N_JOBS); 11 bzero (JobIDList, MAX_N_JOBS*sizeof(char)); 8 JobIDMax = 0; 12 9 } 13 10 14 void FreeJobIDs () { 15 free (JobIDList); 11 void FreeJobIDs () { } 12 13 /* return next unique ID, recycle every MAX_N_JOBS */ 14 IDtype 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); 16 23 } 17 24 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.
