Hi there i am writting a process scheduler and im confused at this point in my code below....
When i compile the program, it compiles successfully and decrements the structure member qaunta by -1 continously. But what i want it to do is to decrement the qaunta variable by -1 and then print that variable and move onto the next variable do the same to that one and keep going round until qaunta reaches the value of 0 (round robin fashion). Thanks
Code:
int comp(const void *a, const void *b) {
return ((struct process*)a)->priority - ((struct process*)b)->priority;
}
/* order the priority in the correct order */
qsort(proc, 199, sizeof(*proc), comp);
}
/* Decrement the process qaunta */
for ( i = 0; i < 199; i++ ) {
printf("%s %d %d\n", proc[i].id, proc[i].qaunta, proc[i].priority);
while (proc[i].qaunta != 0 ) {
proc[i].qaunta = proc[i].qaunta - 1;
printf("%s Qaunta: %d \n",proc[i].id, proc[i].qaunta);
if (proc[i].qaunta == 0 )
printf("Goodbye\n");
}
Heres the end of my output (its continous throughout):
Process10 Qaunta: 150
..................................
Process10 Qaunta: 0