Green University of Bangladesh: Department of Computer Science and Engineering
Green University of Bangladesh: Department of Computer Science and Engineering
Green University of
Bangladesh
Lab Report: 01
Code
#include <stdio.h>
int main()
{
int array[100], n, c, d, swap;
return 0;
}
Output
FCFS Algorithm
Theory: FCFS stands for First Come First Serve. In the FCFS scheduling algorithm, the job that arrived
first in the ready queue is allocated to the CPU and then the job that came second and so on. We can say
that the ready queue acts as a FIFO (First In First Out) queue thus the arriving jobs/processes are placed
at the end of the queue. FCFS is a non-preemptive scheduling algorithm as a process holds the CPU until
it either terminates or performs I/O. Thus, if a longer job has been assigned to the CPU then many
shorter jobs after it will have to wait. This algorithm is used in most of the batch operating systems.
Code
#include <stdio.h>
int main()
scanf("%d", &n);
scanf( "%d",&bustime[i]);
}
w_time[0]=0;
avg_wt=0;
avg_tt=t_time[0]=bustime[0];
{w_time[i]=w_time[i-1]+bustime[i-1];
t_time[i]=w_time[i]+ bustime[i];
avg_wt+=w_time[i];
avg_tt+=t_time[i];
avg_wt =avg_wt/n;
avg_tt =avg_tt/n;
printf( "\n p%d \t\t %d\t\t %d\t\t %d\n" ,i, bustime[i] ,w_time[i], t_time[i]);
}
printf("avarage wating time %f\n",avg_wt );
return 0;
Output
Theory: First come first serve (FCFS) scheduling algorithm simply schedules the jobs
according to their arrival time. The job which comes first in the ready queue will get the CPU
first. The lesser the arrival time of the job, the sooner will the job get the CPU.
Code
#include <stdio.h>
int main()
scanf("%d", &n);
scanf( "%d",&bustime[i]);
for(i=0;i<n;i++)
scanf("%d",&arr_t[i]);
}
w_time[0]=0;
avg_wt=0;
avg_tt=t_time[0]=bustime[0];
{w_time[i]=w_time[i-1]+bustime[i-1];
t_time[i]=w_time[i]+ bustime[i];
avg_wt+=w_time[i];
avg_tt+=t_time[i];
avg_wt =avg_wt/n;
avg_tt =avg_tt/n;
printf( "process\t burst time \t arrival time \t waiting time\t turnaround time\n");
printf( "\n p%d\t %d\t\t %d \t\t %d\t\t %d\n " ,i, bustime[i] ,arr_t[i] ,w_time[i], t_time[i]);
return 0;
Output