| unix shell script
|
syah

msg:4444580 | 8:44 am on Apr 24, 2012 (gmt 0) | i need to convert this to unix shell script
#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[b][i]); printf("\nenter no .of process"); scanf("%d",&p); printf("\nenter allocation resources"); for(i=0;i<p;i++) { f[i]=0; for(j=0;j<n1;j++) scanf("%d",&a1[i][j]); } for(i=0;i<p;i++) for(j=0;j<n1;j++) { if(a1[i][j]<=t[b][j]) { t[b][j]+=a1[i][j]; continue; } else printf("\n wrong resourcesallocation"); printf("\n chance of deadlock occurrence after allocation"); for(j=0;j<n1;j++) printf("%d",a1[b][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[i][j]); n[i][j]=max[i][j]-a1[i][j]; } j=0; printf("\n needed resources for every process to start execution"); for(i=0;i<p;i++) printf("\n%d %d%d",n[i][j],n[i][j+1],n[i][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[i]==0) { if(n[i][j]<=a1[b][j]&&n[i][j+1]<=a1[b][j+1]&& n[i][j+2]<=a1[b][j+2]) { printf("\n process %d execution started and completed",i+1); for(k=0;k<n-1;k++) a1[b][k]+=a1[i][k]; f[i]=1; c++; } else f[i]=0; } } getch(); } [edited by: bill at 4:08 am (utc) on Apr 26, 2012] [edit reason] replaced curly quotes with straight quotes [/edit]
|
|