hello people, I have got a problem. I have written a program to simulate round robin scheduling program using visual c++ , version 6.0. Now, I want to add some simple graphics in my code so that a graphical representation of RR scheduling can be made. But, I don't know how to add graphics in visual c++. Can anyone of you give a suggestion or advice on how to do it? Can you give me a sample code so that I can understand how to change my code to add graphics in it? I think It can a circle showing the processes and time slices. But how to do it? Can you help me in this regard? Thanks.
Here is the program:
#include<stdio.h>
#include<conio.h>
struct round{
char name[20];
int at,bt,wt,trn,prev,ord,rem,cp,q,tc;
};
struct round Q[20],temp;
int main()
{
int f=0,r,i,j,k=0,n,q=0,exe=0,idle=0;
int tt=0,qt,wt=0,awt=0,flag=0,min=0;
float turn=0.0,wait=0.0;
printf("enter the number of process:");
scanf("%d",&n);
printf("enter the quantum:");
scanf("%d",&qt);
for(r=0;r<n;r++)
{
printf("\n Enter process name:");
scanf("%s",Q[r].name);
}
for(r=0;r<n;r++){
printf("\n Enter process %s arrival time:",Q[r].name);
scanf("%d",&Q[r].at);
}
for(r=0;r<n;r++){
printf("\n Enter process %s duration time:",Q[r].name);
scanf("%d",&Q[r].bt);
}
for(r=0;r<n;r++){
printf("\n Enter process %s order:",Q[r].name);
scanf("%d",&Q[r].ord);
}
for(i=0;i<n;i++){
for(j=i+1;j<n;j++){
if(Q[i].ord>Q[j].ord)
{
temp=Q[i];
Q[i]=Q[j];
Q[j]=temp;
}
}
}
min=Q[0].at;
for(i=0;i<n;i++){
if(min>Q[i].at){
min=Q[i].at;
}
}
for(i=0;i<n;i++){
exe=exe+Q[i].bt;
Q[i].cp=Q[i].at;
Q[i].tc=Q[i].at;
Q[r].wt=0;
}
printf("\n sequence of job:");
if(min!=0){
idle+=min;
}
while(tt<exe){
for(i=0;i<n;i++){
if((Q[i].tc<=tt)){
if(Q[i].bt>qt){
flag=1;
Q[i].wt=tt-Q[i].prev-Q[i].cp;
awt=awt+Q[i].wt;
if((Q[i].wt!=0)&&(Q[i].prev==0)){
Q[i].q=Q[i].wt;
}
Q[i].bt=Q[i].bt-qt;
tt+=qt;
Q[i].prev=tt;
printf("%s ",Q[i].name);
Q[i].cp=0;
Q[i].tc=tt;
}
else
{
if(Q[i].bt!=0){
flag=1;
Q[i].wt=tt-Q[i].prev-Q[i].cp;
awt=awt+Q[i].wt;
tt+=Q[i].bt;
Q[i].bt=0;
if((Q[i].wt!=0)&&(Q[i].prev==0)){
Q[i].q=Q[i].wt;
}
Q[i].prev=tt;
if(Q[i].bt==0){
Q[i].trn=tt-(Q[i].at+Q[i].q);
k+=Q[i].trn;
}
printf("%s ",Q[i].name);
Q[i].cp=0;
Q[i].tc=tt;
}
}
}
}
if(flag==0){
tt+=1;
idle+=1;
}
flag=0;
}
printf("\n Total Execution time:");
printf("%d",tt);
wait=(float)awt/n;
printf("\n Avarage Waiting time:");
printf("%.3f",wait);
printf("\n Avarage turnaround time:");
turn=(float)k/n;
printf("%.3f",turn);
printf("\n idle:%d",idle);
printf("\n");
return 0;
}