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