Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
- The problem statement, all variables and given/known data:
shell scripts to simulate Banker�s algorithm on a collection of processes (process details are entered as inputs at the beginning of the simulation) and a comparison when an allocation is modified.
- Relevant commands, code, scripts, algorithms:
i have source code in c
#include<stdio.h>
#include<conio.h>
main()
{
int i,j,a=0,b=0,c=0,f[10],t[10][10],al[10][10],ta[10][10];
int a1[10][10], max[10][10], n[10][10], n1,p,k=0;
printf(�\n enter no.of resources�);
scanf(�%d�,n1);
printf(�\nenter the max no .of resources for each type�);
for(i=0;i<n1;i++)
{
scanf(�%d�,&t);
}
printf(�\nenter no .of process�);
scanf(�%d�,&p);
printf(�\nenter allocation resources�);
for(i=0;i<p;i++)
{
f=0;
for(j=0;j<n1;j++)
{
scanf(�%d�,&a1[j]);
}
}
for(i=0;i<p;i++)
{
for(j=0;j<n1;j++)
{
if(a1[j]<=t[j])
{
t[j]+=a1[j];
continue;
}
else
printf(�\n wrong resources allocation�);
}
printf(�\n chance of deadlock occurrence after allocation�);
for(j=0;j<n1;j++)
{
printf(�%d�,a1[j]);
}
printf(�\n enter the max resources for every process�);
for(i=0;i<p;i++)
{
for(j=0;j<n1;j++);
{
scanf(�%d�,&max[j]);
n[j]=max[j]-a1[j];
}
}
printf(�\n needed resources for every process to start execution�);
for(i=0;i<p;i++)
{
printf(�\n%d %d%d�,n[j],n[j+1],n[j+2]);
}
printf(�\n safe sequence the sequence of process to compute their execution�);
for(a=0;a<(p-c);)
{
for(i=0;i<p;i++)
{
j=0;
b=0;
if(f==0)
{
if(n[j] <= a1[j] && n[j+1] <= a1[j+1] && n[j+2] <= a1[j+2])
{
printf(�\n process %d execution started and completed�,i+1);
for(k=0;k<n-1;k++)
{
a1[k]+=a1[k];
}
f=1;
c++;
}
else
f=0;
}
}
getch();
}
- The attempts at a solution (include all code and scripts):
#!/bin/bash
echo "enter no.of resources: "
read n1
echo -n "enter the max no .of resources for each type: "
for(( i=0; i <$n1; i++ ))
do
read ${t}
done
echo -n "enter no .of process: "
read p
echo -n "enter allocation resources: "
for((i=0;i<p;i++))
do
f=0
for((j=0;j<$n1;j++))
do
read ${a1}
done
done
- Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
MMU Cyber, Cyberjaya, Malaysia, Mr. Timothy, tos 2111
Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).