468,484 Members | 1,749 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,484 developers. It's quick & easy.

scheduling program

4
im looking for a codes of scheduling w/c is shortest job first(non preEmptive) in operating system using a c++ language..
Feb 18 '08 #1
4 11849
sicarie
4,677 Expert Mod 4TB
Well, aside of posting in the wrong forum, what do you have so far?
Feb 18 '08 #2
cyrine
4
Well, aside of posting in the wrong forum, what do you have so far?

a code using visual basic.. first come first serve
i want to translate this into turbo C++ but shortest job first NP
Feb 19 '08 #3
Meetee
931 Expert Mod 512MB
a code using visual basic.. first come first serve
i want to translate this into turbo C++ but shortest job first NP
Yes, agree! But you need to read posting guidelines. We do not provide direct code in this community. Scheduling algorithm's algorithms are easily available by searching google. You can apply logic accordingly. Kindly narrate your problem here if you find any.

Regards
Feb 19 '08 #4
cyrine
4
Yes, agree! But you need to read posting guidelines. We do not provide direct code in this community. Scheduling algorithm's algorithms are easily available by searching google. You can apply logic accordingly. Kindly narrate your problem here if you find any.

Regards

pls help me to translate this into a visual basic language..

// PROGRAM FOR SJF - NON PREEMPTIVE SCHE
// DULING ALGORITHM
//PREPROCESSOR DIRECTIVES
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<iostream.h>
//GLOBAL VARIABLES - DECLARATION
int Twt,Ttt,A[20],Wt[20],n,Bu[20];
float Att,Awt;
char pname[20][20];
//FUNCTION DECLARATIONS
void Getdata();
void Gantt_chart();
void Sjf();
//GETTING THE NUMBER OF PROCESSES AND TH
// E BURST TIME AND ARRIVAL TIME FOR EACH P
// ROCESS
void Getdata()


{
int i;
cout<<"\n Enter the number of processes: ";
cin>>n;
for(i=1;i<=n;i++)


{
fflush(stdin);
cout<<"\n\n Enter the process name: ";
cin>>pname[i];
cout<<"\n Enter The BurstTime for Process: "<<pname[i]<<endl;
cin>>Bu[i];
cout<<"\n Enter the Arrival Time for Process: "<<pname[i]<<endl;
cin>>A[i];
}
}

//DISPLAYING THE GANTT CHART
void Gantt_chart()


{
int i;
cout<<"\n\nGANTT CHART";
cout<<"\n--------------------------------------------------------------------\n"<<endl;
for(i=1;i<=n;i++)
cout<<pname[i];
cout<<"|\t\n";
cout<<"\n-----------------------------------------------------------\n";
cout<<"\n"<<endl;
for(i=1;i<=n;i++)
cout<<Wt[i]<<endl;
cout<<Wt[n]+Bu[n]<<endl;
cout<<"\n--------------------------------------------------------------------\n";
cout<<"\n";
}

//Shortest job First Algorithm with NonPreemption
void Sjf()


{
int w,t,i,B[10],Tt=0,temp,j;
char S[10],c[20][20];
int temp1;
cout<<"\n\n SHORTEST JOB FIRST SCHEDULING ALGORITHM \n\n"<<endl;
Twt=Ttt=0;
w=0;
for(i=1;i<=n;i++)


{
B[i]=Bu[i];
S[i]='T';
Tt=Tt+B[i];
}
for(i=1;i<=n;i++)


{
for(j=3;j<=n;j++)


{
if(B[j-1]>B[j])


{
temp=B[j-1];
temp1=A[j-1];
B[j-1]=B[j];
A[j-1]=A[j];
B[j]=temp;
A[j]=temp1;
strcpy(c[j-1],pname[j-1]);
strcpy(pname[j-1],pname[j]);
strcpy(pname[j],c[j-1]);
}
}
}
//For the 1st process
Wt[1]=0;
w=w+B[1];
t=w;
S[1]='F';
while(w<Tt)


{
i=2;
while(i<=n)


{
if(S[i]=='T'&&A[i]<=t)


{
Wt[i]=w;
S[i]='F';
w=w+B[i];
t=w;
i=2;
}
else
i++;
}
}
//CALCULATING AVERAGE WAITING TIME AND AVERAGE TURN AROUND TIME
for(i=1;i<=n;i++)


{
Twt=Twt+(Wt[i]-A[i]);
Ttt=Ttt+((Wt[i]+Bu[i])-A[i]);
}
Att=(float)Ttt/n;
Awt=(float)Twt/n;
cout<<"\n\n Average Turn around time=%3.2f ms "<<Att;
cout<<"\n\n AverageWaiting Time=%3.2f ms"<<Awt;
Gantt_chart();
}

void main()


{
clrscr();
Getdata();
Sjf();
getch();
}
Feb 21 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by Gilles Leblanc | last post: by
6 posts views Thread by Tony Proctor | last post: by
reply views Thread by steve | last post: by
3 posts views Thread by Alphonse Giambrone | last post: by
4 posts views Thread by Dinsdale | last post: by
2 posts views Thread by kmdo | last post: by
Ritchie
2 posts views Thread by Ritchie | last post: by
reply views Thread by theflame83 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.