Professional Documents
Culture Documents
CSE 2005 - Operating Systems Assessment - 2: Name: Jayanth Adm - No: 20BCE0967
CSE 2005 - Operating Systems Assessment - 2: Name: Jayanth Adm - No: 20BCE0967
Name: Jayanth
Adm.no: 20BCE0967
Question:
A single processor system has three resource types X, Y and Z, which are shared by three processes.
There are 5 units of each resource type. Consider the following scenario, where the column alloc
denotes the number of units of each resource type allocated to each process, and the column
request denotes the number of units of each resource type requested by a process in order to
complete execution. Which of these processes will finish LAST?
1. P0
2. P1
3. P2
int max[3][3] = { { 2, 2, 4 }, // P0
{ 2, 1, 3 }, // P1
{ 3, 4, 1 }}; // P2
int flag = 0;
for (j = 0; j < m; j++) {
if (need[i][j] > avail[j]){
flag = 1;
break;
}
}
if (flag == 0) {
ans[ind++] = i;
for (y = 0; y < m; y++)
avail[y] += alloc[i][y];
f[i] = 1;
}
}
}
}
return (0);
Output: