#include #define SLICE 4 #define MAXT 25 int main(void) { char names[2] = {'A', 'B'}; int rem[2] = {20, 5}; int prio[2] = {2, 2}; int used[2] = {0, 0}; int arr[2] = {0, 12}; printf("MLFQ sim: 3 levels, slice=%d\n", SLICE); printf("Gantt (A=long CPU, B=short arr@12):\n"); for(int t=0; t0 && prio[i]>bp) { bp=prio[i]; best=i; } } if(best<0) { putchar('.'); continue; } putchar(names[best]); rem[best]--; used[best]++; if(used[best]>=SLICE) { if(prio[best]>0) prio[best]--; used[best]=0; } } printf("\n"); printf("Final remaining A=%d B=%d\n", rem[0], rem[1]); return 0; }