Beruflich Dokumente
Kultur Dokumente
1
Aim :-
Write the pseudo code in Linux using C/C++ to perform FCFS scheduling.
Theory :
FCFS also termed as First-In-First-Out i.e. allocate the CPU in order in which the process arrive.
When the CPU is free, it is allowed to process, which is occupying the front of the queue. Once
this process goes into running state, its PCB is removed from the queue. This algorithm is non-
preemptive. Suitable for batch system. It is simple to understand and code. Waiting time can be
large if short request wait behind the long process. It is not suitable for time sharing system where
it is important that each user should get the CPU for equal amount of time interval.
FCFS Scheduling
Code:-
#include<stdio.h>
int main(){int n,AT[10],BT[10],WT[10],G[10],i,m;
float Avg_wt=0;for(i=0;i<1;i++){ AT[i]=0;BT[i]=0;WT[i]=0;G[i]=0;}
printf ("Enter the number of processes: \t");
scanf("%d",&n);for(i=0;i<n;i++){
printf ("Enter the Arrival time & Burst time for process no %d:", i );
scanf("%d",&AT[i]);
scanf("%d",&BT[i]);}
for(i=0;i<n;i++)
{ WT[i]=G[i] - AT[i]; Avg_wt = Avg_wt + WT[i];G[i+1]= G[i]+ BT[i];}
Avg_wt = Avg_wt/n ;
printf ("\n\t Process\t Arrival time \t Ext_ Time\t Waiting time\t \n");
for (i=0;i<n;i++)
{ printf("\t %d\t \t %d\t\t %d\t \t %d\t\t\n",i,AT[i],BT[i],WT[i]);}
printf("\n The average waiting time is %f \n", Avg_wt);
}
Output:-
Conclusion:
Thus we have successfully performed FCFS scheduling.
Experiment No. 2
Aim :-
Write the pseudo code in Linux using C/C++ to perform Round Robin scheduling.
Theory :
Round Robin is the preemptive process scheduling algorithm. Each process is provided a fix time
to execute, it is called a time quantum. Once a process is executed for a given time period, it is
preempted and other process executes for a given time period. Context switching is used to save
states of preempted processes.
Output:
Conclusion:
Thus we have performed round robin scheduling.
Experiment No. 3
Aim:-
Write the pseudo code in Linux using C/C++ to perform Priority Based scheduling
Theory :
Priority scheduling is a non-preemptive algorithm and one of the most common scheduling
algorithms in batch systems. Each process is assigned a priority. Process with highest priority is to
be executed first and so on. Processes with same priority are executed on first come first served
basis. Priority can be decided based on memory requirements, time requirements or any other
resource requirement.
Conclusion:
Thus we have performed priority scheduling algorithm and verified timings of all three different types
of algorithm in three experiments.