Skip to content
Snippets Groups Projects
Commit c7f214d4 authored by Elizabeth Baker's avatar Elizabeth Baker
Browse files

Merge remote-tracking branch 'origin/master' into alternative_ending

# Conflicts:
#	allocate.c
parents b47675d8 4867c68c
No related branches found
No related tags found
No related merge requests found
......@@ -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 );
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment