SIMULATION OF FIRST IN FIRST OUT(FIFO) PROCESS SCHEDULING USING C PROGRAM

AIM:
To write a c program in UNIX environment to implement the following scheduling discipline
First In First Out (FIFO)
FIFO:
FIFO is the simplest discipline processes are dispatched according to their arrival time on the ready queue. Once a process has the CPU if runs to completion. FIFO is a non-preemptive discipline. if is fain in the formal sense but somewhat unfair in that long jobs make short jobs wait, and unimportant jobs make important jobs wait.


ALGORITHM: OPERATING SYSTEM (OS) LAB IN LINUX ENVIRONMENT



· Get the number of process from the user.

· Get also cpu service time for each process from the user.

· For each process the waiting time is equivalent to CPU time of previous process.

· The ratio of waiting time of all the process to the number of process will give the average waiting time.

· Display the result.


PROGRAM SOURCE CODE

# include<stdio.h>
main()
{
int k=0,ptime[25],n,s=0,I,sum=0;
char name[25][25];
float avg;
printf (“enter the no. of process: \t”);
scanf (“%d”,&n);
for(i=0;i<n;i++)
{
printf(“enter the name for processes: \t”);
printf(“%d \t”,i+1);
scanf(“%s”,name[i]);
}
printf(“\n \n”);
for(i=0;i<n;i++)
{
printf(“enter the process time: \t”);
printf(“%s \t”,name[i]);
scanf(“%d”,&ptime[i]);
}
printf(“\n \n”);
printf(“\n process – name \t process – time \n”);
for(i=0;i<n;i++)
{
printf(“\t %s \t \t %d \n”,name[i],ptime[i]);
}
printf(“\n \n FIFO SCHEDULING \n \n”);
for(i=0;i<n;i++)
{
printf(“process %s from %d to %d \n”, name[i],k,(k+ptime[i]));
k+=ptime[i];
}
for(i=0;i<(n-1);i++)
{
s+=ptime[i];
sum+=s;
}
avg=(float)sum/n;
printf(“\n\n average waiting time: \t”);
printf(“%2fmsec”,avg);
sum=avg=s=0;
for(i=0;i<n;i++)
{
s+=ptime[i];
sum+=s;
}
avg=(float)sum/n;
printf(“\n turn around time is \t”);
printf(“%2fmsec”,avg);
}

CONCLUSION:
Thus the c program for FIFO scheduling discipline was written and executed successfully.

Related post