Changeset 40424 for trunk/Ohana/src/opihi/pantasks
- Timestamp:
- May 15, 2018, 8:56:30 AM (8 years ago)
- Location:
- trunk/Ohana/src/opihi/pantasks
- Files:
-
- 5 edited
-
CheckController.c (modified) (1 diff)
-
JobIDOps.c (modified) (1 diff)
-
JobOps.c (modified) (5 diffs)
-
delete.c (modified) (1 diff)
-
kill.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/pantasks/CheckController.c
r39476 r40424 7 7 8 8 char *p, *q; 9 int i, Njobs, status, JobID; 9 int i, Njobs, status; 10 IDtype JobID; 10 11 Job *job; 11 12 IOBuffer buffer; -
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) */ -
trunk/Ohana/src/opihi/pantasks/JobOps.c
r38559 r40424 41 41 42 42 /* return job with given ID */ 43 Job *FindJob ( intJobID) {43 Job *FindJob (IDtype JobID) { 44 44 45 45 int i; … … 55 55 56 56 /* return job with given controller Job ID */ 57 Job *FindControllerJob ( intJobID) {57 Job *FindControllerJob (IDtype JobID) { 58 58 59 59 int i; … … 82 82 gprint (GP_LOG, " Jobs in Pantasks Queue\n"); 83 83 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]); 85 85 } 86 86 … … 97 97 98 98 job[0].JobID = NextJobID (); 99 100 // this should not happen; abort? 99 101 if (job[0].JobID < 0) { 100 102 free (job); … … 165 167 if (job == NULL) return; 166 168 167 FreeJobID (job[0].JobID);168 169 169 for (i = 0; i < job[0].argc; i++) { 170 170 free (job[0].argv[i]); -
trunk/Ohana/src/opihi/pantasks/delete.c
r23530 r40424 4 4 5 5 Job *job; 6 intJobID;6 IDtype JobID; 7 7 8 8 if (argc != 3) goto usage; -
trunk/Ohana/src/opihi/pantasks/kill.c
r23530 r40424 4 4 5 5 Job *job; 6 intJobID;6 IDtype JobID; 7 7 8 8 if (argc < 2) { … … 10 10 return (FALSE); 11 11 } 12 JobID = ato i(argv[1]);12 JobID = atoll (argv[1]); 13 13 14 14 JobTaskLock();
Note:
See TracChangeset
for help on using the changeset viewer.
