Lab No. 7: Lab Manual For Operating System
Lab No. 7: Lab Manual For Operating System
Lab No. 7
First Come First Serve Scheduling Algorithm
Objectives
To understand basic concept, working and usage of scheduling algorithm.
LAB # 07
The FCFS Scheduling Algorithm
Short-Term Scheduling
Short-term scheduling, or dispatching, involves scheduling processes to execute on a processor.
Whenever the CPU becomes idle, the operating system must select one of the processes in the ready
queue to be executed. The selection process is carried out by the short-term scheduler. It selects a
process from the processes in memory that are ready to execute and allocates the CPU to that process.
There are various algorithms available for scheduling processes. Some of these are discussed in this
manual while the rest are left for the students as tasks.
The codes provided in Example#01 and Example#02 are implementations of the FCFS algorithms. In the
code provided in Example#01, it is assumed that all processes are present in the system at the same
time; that is, all processes have arrived in the system. However, the processes usually arrive at different
times. In order to accommodate processes arriving at different times, the code in Example#01 can be
modified as given in Example#02.
#include<stdio.h>
void main (void)
{
int st[20], wt[20], tat[20], i, n;
float wt_avg, tat_avg;
#include<stdio.h>
void main (void)
{
int at[20], st[20], wt[20], ft[20], tat[20], i, n;
float wt_avg, tat_avg;
}
Lab Tasks/Practical Work
1) Implement the codes of Example#01 and Example#01. Discuss what you have learned after
implementing and executing these two codes. Provide snapshots of the generated outputs.
2) The FCFS source code given above assumes that the arrival times for processes are provided in
ascending order of time. Modify the code in C language for random process arrival times.
3) Modify the FCFS code of example#02 to be able to calculate the mean of Normalized Turnaround
Time. Also the modified code should display the Normalized Turnaround Time of each process.