diff --git a/allocate.c b/allocate.c index a458cfbbdcf862a1360ea4a43c488670479429f9..9ffc42e9614c50cde3e200781bac41b3c2fba581 100644 --- a/allocate.c +++ b/allocate.c @@ -20,12 +20,14 @@ typedef struct { int timeRemaining; int subProcsRunning; int justStarted; + int deltaTime; } process; typedef struct { //int CPUi; int totalExecutionTimeRemaining; //add all the times of the process llist *processQueue; + int numPorc; } CPU; void initializeProcess(char data[], process *newProcess); @@ -176,8 +178,8 @@ int main(int argc, char *argv[]) { if (headProcess != NULL && headProcess->justStarted) { // printf("current time: %d\n", currentTime); headProcess->justStarted = 0; - printf("%d,RUNNING,pid=%s,remaining_time=%d,cpu=%d\n", - currentTime, headProcess->processID, headProcess->timeRemaining, j); + printf("%d,RUNNING,pid=%s,remaining_time=%d,cpu=%d - AAAA line 184\n", + deltaTime+1, headProcess->processID, headProcess->timeRemaining, j); } } @@ -291,7 +293,7 @@ void initializeProcess(char data[], process *newProcess) { if (token != NULL) { newProcess->parallelisable = token[0]; } - + newProcess->deltaTime =0; newProcess->timeCompleted = -1; newProcess->timeRemaining = newProcess->executionTime; } @@ -355,7 +357,11 @@ void advanceProcessQueue(llist *processQueue, int currentTime, int deltaTime, ll } llist_pop(processQueue); headProcess = headData(processQueue); - if (headProcess) headProcess->justStarted = -1; + if (headProcess){ + headProcess->justStarted = -1; + headProcess->deltaTime = deltaTime; + } + } else { // finishedprocess is not parallelisable *numProcessesLeft -= 1; *numProcessComplete += 1; @@ -365,12 +371,15 @@ void advanceProcessQueue(llist *processQueue, int currentTime, int deltaTime, ll llist_push(processesComplete, headProcess); llist_pop(processQueue); headProcess = headData(processQueue); - if (headProcess) headProcess->justStarted = -1; + if (headProcess){ + headProcess->justStarted = -1; + headProcess->deltaTime = deltaTime; + } } } else { // head process not finished headProcess->timeRemaining -= deltaTime; - + headProcess->deltaTime = deltaTime; deltaTime = 0; // llist_print( processQueue, (void (*)(void *)) &printQEntry ); }