import java.util.*;
class shortest
{
int at,bt,st,wt,pid;
shortest()
{
Scanner src=new Scanner(System.in);
System.out.println("enter Burst time:");
bt=src.nextInt();
}
}
class test
{
public static void main(String args[])
{
Scanner src=new Scanner(System.in);
System.out.println("enter the no.of process");
int n=src.nextInt();
shortest obj[]=new shortest[n];
for(int i=0;i<=n-1;i++)
{
System.out.println("process"+(i+1));
System.out.println("__________________");
obj[i]=new shortest();
obj[i].pid=i+1;
}
//shortest t[];
obj=sorting(obj);
display(obj);
}
static shortest[] sorting(shortest temp[])
{
for(int i=0;i<=temp.length-2;i++)
for(int j=i+1;j<=temp.length-1;j++)
{
if(temp[i].bt>temp[j].bt)
{
shortest temp2=temp[i];
temp[i]=temp[j];
temp[j]=temp2;
}
}
return temp;
}
static void display(shortest temp[])
{
temp[0].st=0;
temp[0].wt=0;
int w=0;
for(int i=1;i<=temp.length-1;i++)
{
w=w+temp[i-1].bt;
temp[i].st=w;
}
System.out.println("pid\tburst\tstart");
for(int i=0;i<=temp.length-1;i++)
{
System.out.println(temp[i].pid+"\t"+temp[i].bt+"\t"+temp[i].st);
}
}
}
Saturday, February 13, 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment