diff --git a/allocate.c b/allocate.c index d7ef5f33e120d40378999440c50d85a78e9b95c7..d7e4a4eefe0183a627ce3c5950b8965214366b5f 100644 --- a/allocate.c +++ b/allocate.c @@ -28,7 +28,7 @@ typedef struct { //int CPUi; int totalExecutionTimeRemaining; //add all the times of the process llist *processQueue; - int numPorc; + int numProcessesRemaining; } CPU; void initializeProcess(char data[], process *newProcess); @@ -106,11 +106,7 @@ int main(int argc, char *argv[]) { //main loop if (f != NULL) { - - //iterate over arriving processes - - - //while (fgets(line, sizeof line, f) != NULL) { + // iterate over arriving processes while (newProcess = getNextProcessB(f, arrivalLounge, readAhead)) { //printf("process id:%s process arrival time: %d\n", newProcess->processID, newProcess->timeArrived); @@ -167,6 +163,7 @@ int main(int argc, char *argv[]) { parableProcess[i].timeRemaining = parableProcess[i].executionTime; parableProcess[i].timeRemAtStartTime = newProcess->timeRemAtStartTime; addProcessToQueue(CPUs[i].processQueue, ¶bleProcess[i], currentTime, i); + CPUs[i].totalExecutionTimeRemaining += newProcess->executionTime; } numProcessesLeft += 1; llist_push(paralellizedProcesses, newProcess); @@ -245,6 +242,7 @@ int main(int argc, char *argv[]) { } // currentTime += deltaTime; + } } // printf("Completed Queue:"); // llist_print(completedProcesses, (void (*)(void *)) &printQEntry); @@ -367,8 +365,10 @@ void advanceProcessQueue(llist *processQueue, int currentTime, int deltaTime, ll paralizedProcess->timeRemaining = 0; headProcess->timeRemaining = 0; //printf("process had finished: Current time: %d, deltaTime: %d\n", currentTime, deltaTime); -// // Could accumulate statistics here instead of keeping list of completed processes -// llist_push(processesComplete, paralizedProcess); +// printf("%d,FINISHED,pid=%s,proc_remaining=%d\n", +// paralizedProcess->timeCompleted, paralizedProcess->processID, *numProcessesLeft); + // Could accumulate statistics here instead of keeping list of completed processes + llist_push(processesComplete, paralizedProcess); } llist_pop(processQueue); headProcess = headData(processQueue); @@ -381,8 +381,8 @@ void advanceProcessQueue(llist *processQueue, int currentTime, int deltaTime, ll } else { // finishedprocess is not parallelisable *numProcessesLeft -= 1; *numProcessComplete += 1; - printf("%d,FINISHED,pid=%s,proc_remaining=%d\n", - headProcess->timeCompleted, headProcess->processID, *numProcessesLeft); +// printf("%d,FINISHED,pid=%s,proc_remaining=%d\n", +// headProcess->timeCompleted, headProcess->processID, *numProcessesLeft); // Could accumulate statistics here instead of keeping list of completed processes llist_push(processesComplete, headProcess); llist_pop(processQueue);