Professional Documents
Culture Documents
20.03.21
1.FIRST FIT:
class GFG
allocation[i] = -1;
allocation[i] = j;
blockSize[j] -= processSize[i];
T.PRABAVATHI(20MA32)
break;
processSize[i] + "\t\t");
if (allocation[i] != -1)
System.out.print(allocation[i] + 1);
else
System.out.print("Not Allocated");
System.out.println();
int m = blockSize.length;
int n = processSize.length;
T.PRABAVATHI(20MA32)
2. BEST FIT:
allocation[i] = -1;
if (bestIdx == -1)
bestIdx = j;
T.PRABAVATHI(20MA32)
bestIdx = j;
if (bestIdx != -1)
allocation[i] = bestIdx;
blockSize[bestIdx] -= processSize[i];
if (allocation[i] != -1)
System.out.print(allocation[i] + 1);
else
System.out.print("Not Allocated");
System.out.println();
// Driver Method
T.PRABAVATHI(20MA32)
int processSize[] = {212, 417, 112, 426};
int m = blockSize.length;
int n = processSize.length;
3. WORST FIT:
allocation[i] = -1;
T.PRABAVATHI(20MA32)
// Find the best fit block for current process
if (wstIdx == -1)
wstIdx = j;
wstIdx = j;
if (wstIdx != -1)
allocation[i] = wstIdx;
blockSize[wstIdx] -= processSize[i];
if (allocation[i] != -1)
System.out.print(allocation[i] + 1);
else
T.PRABAVATHI(20MA32)
System.out.print("Not Allocated");
System.out.println();
// Driver Method
int m = blockSize.length;
int n = processSize.length;
T.PRABAVATHI(20MA32)