Calculate bestSolutionLength correctly
This commit is contained in:
parent
72da8e371b
commit
5398b9dccd
10
supervisor.c
10
supervisor.c
@ -106,12 +106,17 @@ void getSolution(sem_t *sUsedSpace, sem_t *sFreeSpace)
|
||||
int bestSolutionLength = 0;
|
||||
int newSolutionLength = 0;
|
||||
|
||||
// Compute length of current bestSolution
|
||||
if (bestSolution[0] != -1) {
|
||||
for (int i = 0; i < MAX_ITEMS; i++) {
|
||||
if ((bestSolution[i] == -1) && (i != 0)) {
|
||||
bestSolutionLength = i+1;
|
||||
if (bestSolution[i] == -1) {
|
||||
bestSolutionLength = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Compute length of newSolution
|
||||
for (int i = 0; i < MAX_ITEMS; i++) {
|
||||
if ((solution[i] == -1) && (i != 0)) {
|
||||
newSolutionLength = i+1;
|
||||
@ -121,6 +126,7 @@ void getSolution(sem_t *sUsedSpace, sem_t *sFreeSpace)
|
||||
|
||||
if (newSolutionLength == 0) {
|
||||
printf("[%s] The graph is acyclic!\n", pname);
|
||||
quit = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user