0% found this document useful (0 votes)
29 views4 pages

EX 3 - Scheduling Algorithms

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

EX 3 - Scheduling Algorithms

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

SRI SIVASUBRAMANIYA NADAR COLLEGE OF ENGINEERING, KALAVAKKAM

(An Autonomous Institution, Affiliated to Anna University, Chennai)

Department of Computer Science and Engineering

UCS2412 – Operating Systems Laboratory

II Year CSE –A, B, C Sections (IV Semester)

Academic Year 2023-24

Exercise – 3 – Scheduling Algorithms -FCFS, SJF

Lab Exercise 3 Implementation of Scheduling Algorithms (FCFS, SJF)

Aim:

To develop a C program to implement the Scheduling Algorithms. (K4, CO1)

Scenario:

Consider a hospital scenario, where the patients are waiting for doctor consultation. Identify
the suitable scheduling algorithm for this scenario and develop a solution to schedule the
patients with respect to their token number. Arrival time of the patient is used to decide the
token number, consultation time with the doctor is the burst time.

a. Compute the waiting time, turnaround time and response time of each patient and
tabulate the results with the Gantt chart.

In the above scenario, let us include the following cases that take less consultation time:

● Vaccination

● Showing test reports only

● Medical representatives
b. Identify the suitable scheduling algorithm for this scenario by giving preferences to
the above cases and develop a solution to schedule the consultations.
c. Compute the waiting time, turnaround time and response time of each patient and
tabulate the results with the Gantt chart.
d. Analyze and report the best scheduling algorithm based on the scheduling criteria.
Sample Learning Outcome:

1. Implement the various CPU scheduling algorithms like FCFS and SJF (P and NP)

2. Calculate the waiting time, response time and turn around time for various scheduling algorithms

3. Based on criteria, identify the best scheduling policy

Best Practices:

1. Algorithm design

2. Naming convention – for file names, variables

3. Comment usage at proper places

4. Prompt messages during reading input and displaying output

5. Error handling mechanisms for input like burst time, starting time,

6. Incremental program development

7. Modularity

8. All possible test cases in output

Algorithm:
1. Read the following
a. Number of processes
b. Process IDs
c. Arrival time for each process
d. Burst Time for each process
2. Design a menu with FCFS and SJF options
3. Upon selection of menu option apply the corresponding algorithm.
4. Compute the Turnaround Time, Average waiting Time for each of the algorithm.
5. Tabularize the results.
6. Display the Gantt Chart.
Sample Input & Output:
CPU SCHEDULING ALGORITHMS
1. FCFS
2. SJF
3. EXIT
Enter your option: 1
FCFS CPU SCHEDULER
Number of Processes: 5
Process ID: P1
Arrival Time: 0
Burst Time: 4
-
-
-
-
Process ID: P5
Arrival Time: 6
Burst Time: 3
Output:

Process ID Arrival Time Burst Time Turnaround Time Waiting Time


P1 0 4 *** ***
*** *** *** *** ***
***
***
Average *** ***

Want to Continue ( Y/N): Y


CPU SCHEDULING ALGORITHMS
1. FCFS
2. SJF
3. EXIT
Enter your option: 2
SJF CPU SCHEDULER
a. Non preemptive SJF
b. Pre emptive SJF
Enter your option: a
Number of Processes: 5
Process ID: P1
Arrival Time: 0
Burst Time: 4
-
-
-
-
Process ID: P5
Arrival Time: 6
Burst Time: 3
Output:

Process ID Arrival Time Burst Time Turnaround Time Waiting Time


*** *** *** *** ***
*** *** *** *** ***
***
***
Average *** ***

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy