Lab 3
Lab 3
• 1. Start the program. Get the number of processes and their burst time.
• 2. Initialize the waiting time for process 1 as 0.
• 3. The processes are stored according to their burst time.
• 4.The waiting time for the processes are calculated as follows:
• for(i=2;i<=n;i++), wt.p[i]=p[i=1]+bt.p[i-1].
• 5. The waiting time of all the processes summed and then the average
time is calculate
• 6. The waiting time of each processes and average time are displayed.
• 7. Stop the program.
3. Shortest Remaining time first (SRTF)
i) It is a pre-emptive scheduling algorithm.
ii) It aims to minimize waiting time by choosing the process with the
smallest remaining processing time.
iii) It is more appropriate for interactive systems compared to SJF as it
allows for dynamic adjustments when shorter processes arrive.
iv) Implementation is complex as it requires continuous recalculation of
remaining times and frequent context switching.
v) The processor needs precise and updated knowledge of remaining
CPU time, which can be challenging to maintain accurately.
Algorithm:
1. Get the number of process and their burst time.
2. Traverse until all process gets completely executed.
i. Find process with minimum remaining time at every single time lap.
ii. Reduce its time by 1.
iii.Check if its remaining time becomes 0
iv. Increment the counter of process completion.
v. Completion time of current process = current_time +1;
vi. Calculate waiting time for each completed process.
vii.wt[i]= Completion time - arrival_time-burst_time
viii.Increment time lap by one.
3. The waiting time for each process are displayed.
4. Stop the program.
3. Priority Scheduling
P0 0 4 2
P1 1 3 3
P2 2 1 4
P3 3 5 5
P4 4 2 5