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

"RUNNING" log entries

parent 0cfc08f6
No related branches found
No related tags found
No related merge requests found
......@@ -129,10 +129,8 @@ int main(int argc, char *argv[]) {
CPUs[j].totalExecutionTimeRemaining -= deltaTime;
}
}
if (newProcess->parallelisable == 'n') {
//allocate process to cpu
//allocate process to cpu(s)
if (newProcess->parallelisable == 'n') { // If its not parallelizable just allocate it to queue
int shortestTimeRemaining = 0; //this is the index for the CPU with the shortest time remaining
for (int j = 1; j < numCPU; j++) {
// this is choosing a cpu queue scheduling
......@@ -140,20 +138,19 @@ int main(int argc, char *argv[]) {
shortestTimeRemaining = j;
}
}
//position the new process in the queue
addProcessToQueue(CPUs[shortestTimeRemaining].processQueue, newProcess,
currentTime, shortestTimeRemaining);
numProcessesLeft += 1;
CPUs[shortestTimeRemaining].totalExecutionTimeRemaining += newProcess->executionTime;
} else if (newProcess->parallelisable == 'p') {
} else if (newProcess->parallelisable == 'p') { // Parallelizable processes need to be split up
// calculate number of sub processes and execution times for sub processes
int quot = newProcess->executionTime / numCPU;
int rem = newProcess->executionTime % numCPU;
int nSubProc = numCPU;
if (quot == 0) nSubProc = rem;
newProcess->subProcsRunning = nSubProc;
// create the sub processes
process *parableProcess = malloc(nSubProc * (sizeof(process)));
for (int i = 0; i < nSubProc; i++) {
parableProcess[i].timeArrived = newProcess->timeArrived;
......@@ -180,7 +177,7 @@ int main(int argc, char *argv[]) {
// printf("current time: %d\n", currentTime);
headProcess->justStarted = 0;
printf("%d,RUNNING,pid=%s,remaining_time=%d,cpu=%d\n",
deltaTime+1, headProcess->processID, headProcess->timeRemaining, j);
currentTime, headProcess->processID, headProcess->timeRemaining, j);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment