0% found this document useful (0 votes)
19 views2 pages

EE426 OS Lab3 Spring2023

The document describes a lab experiment on CPU scheduling algorithms with the following objectives: 1. Write programs to simulate FCFS, SJF, priority, and round robin scheduling and calculate their turnaround and waiting times. 2. Write a program to simulate multilevel queue fixed priority scheduling with round robin for higher priority processes and FCFS for lower priority processes. It then provides details on implementing each scheduling algorithm as a C program and sample input data to test each one.

Uploaded by

hiba
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views2 pages

EE426 OS Lab3 Spring2023

The document describes a lab experiment on CPU scheduling algorithms with the following objectives: 1. Write programs to simulate FCFS, SJF, priority, and round robin scheduling and calculate their turnaround and waiting times. 2. Write a program to simulate multilevel queue fixed priority scheduling with round robin for higher priority processes and FCFS for lower priority processes. It then provides details on implementing each scheduling algorithm as a C program and sample input data to test each one.

Uploaded by

hiba
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

M02/EE426 Operating Systems

Lab#3: SCHEDULING ALGORITHMS

Objectives:
The two main objectives of this lab experiment are:
1. Write a C program to simulate the following CPU scheduling algorithms to find turnaround time and waiting
time.
a) FCFS (non-preemptive)
b) SJF (non-preemptive)
d) Priority (non-preemptive)
c) Round Robin (preemptive)
2. Write a C program to simulate multilevel queue fixed priority scheduling algorithm.

Part1: FCFS SCHEDULING ALGORITHM


Write a C program to implement the FCFS scheduling algorithm. Your program should perform the following tasks:
1. Get the number of processes.
2. For each process assign the process ID and get the process CPU burst time.
3. Set the waiting time of the first process as 0 and its turnaround time as its CPU burst time.
4. For each process calculate its waiting time and its Turnaround time.
5. Calculate the average waiting time and turnaround time.
6. Print the Gantt chart.
7. To test your program, use the following data: (‘u’ refers to unit of time)
Process Burst time
P1 4u
P2 5u
P3 6u

Part2: SJF SCHEDULING ALGORITHM


Write a C program to implement the non-preemptive SJF scheduling algorithm. Your program should perform the
following tasks:
1. Get the number of processes.
2. For each process, assign the process ID and get its CPU burst time.
3. Sort the processes according to the CPU burst time.
4. For each process calculate its waiting time and its Turnaround time.
5. Calculate the average waiting time and turnaround time
6. Print the Gantt chart.
7. To test your program, use the following data:

Process Burst time


P1 6 u
P2 3 u
P3 7 u

Part3: PRIORITY SCHEDULING ALGORITHM


Write a C program to implement the PRIORITY scheduling algorithm. Your program should perform the following
tasks:
1. Get the number of processes.
2. For each process assign the process ID and get its CPU burst time and its priority value.
3. Sort the processes according to the priority value.
4. For each process calculate its waiting time and its Turnaround time.
5. Calculate the average waiting time and turnaround time.
6. Print the Gantt chart.
7. To test your program, use the following data: (Priority value ‘1’ is the highest priority).
Process Burst Priority
time
P1 3 u 8
P2 4 u 9
P3 2 u 8
P4 4 u 1

Part4: ROUND ROBIN SCHEDULING ALGORITHM


Write a C program to implement the ROUND ROBIN scheduling algorithm. Your program should perform the
following tasks:
1. Accept the number of processes in the ready queue and time slice (quantum q).
2. For each process in the ready queue accept the burst time.
3. Calculate the number of time slices required for each process.
4. If the burst time is less than the time slice then the number of time slice is 1.
5. Considering the ready queue as a circular queue, calculate
Total waiting time for each process.
Total turnaround time for each process.
6. Calculate the average waiting time and turnaround time.
7. Print the Gantt chart.
8. To test your program, use the following data: (time slice q=5u)

Process Burst time


P1 10 u
P2 5 u

Part5: MULTILEVEL QUEUE FIXED PRIORITY SCHEDULING ALGORITHM


Multilevel queue fixed priority scheduling algorithm is used in scenarios where the processes can be classified into
groups based on property like process type, CPU time, IO access, memory size, etc. In a multilevel queue fixed
priority scheduling algorithm, there will be 'n' number of queues, where 'n' is the number of groups the processes are
classified into. Each queue will be assigned a priority and will have its own scheduling algorithm like RR, SJF or
FCFS. For the process in a queue to execute, all the queues of priority higher than it should be empty, meaning the
process in those high priority queues should have completed its execution. In this scheduling algorithm, once assigned
to a queue, the process will not move to any other queues.

Write a C program to simulate multilevel queue fixed priority scheduling algorithm considering the following
scenario. All the processes in the system are divided into two categories – system processes and user processes.
System processes are to be given higher priority than user processes. Use RR scheduling for system processes and
FCFS scheduling for user processes. Your program should perform the following tasks:
1. For each process calculate its waiting time and its Turnaround time.
2. Print the Gantt chart.
3. To test your program, use the following data:

4. If you consider that the time slice for the RR scheduling is q=2u, then your Gantt chart should be as follows:

You might also like