homepage Welcome to WebmasterWorld Guest from 50.16.130.188
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Visit PubCon.com
Home / Forums Index / Hardware and OS Related Technologies / Linux, Unix, and *nix like Operating Systems
Forum Library, Charter, Moderators: bakedjake

Linux, Unix, and *nix like Operating Systems Forum

    
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]

 

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Hardware and OS Related Technologies / Linux, Unix, and *nix like Operating Systems
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved