0% found this document useful (0 votes)
60 views21 pages

Scheduling. LP1

The document demonstrates the implementation of various CPU scheduling algorithms including first come first serve (FCFS), shortest job first (SJF), shortest remaining time first (SRTF), round robin (RR), and priority scheduling (PS). For each algorithm, the user is prompted to input process details like arrival time and burst time. The output shows the Gantt chart and calculation of average waiting time and turnaround time.

Uploaded by

Khushi Magotra
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)
60 views21 pages

Scheduling. LP1

The document demonstrates the implementation of various CPU scheduling algorithms including first come first serve (FCFS), shortest job first (SJF), shortest remaining time first (SRTF), round robin (RR), and priority scheduling (PS). For each algorithm, the user is prompted to input process details like arrival time and burst time. The output shows the Gantt chart and calculation of average waiting time and turnaround time.

Uploaded by

Khushi Magotra
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/ 21

Scanned by CamScanner

Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
/* OUTPUT

Scheduling Algorithms Menu


==========================

1. First Come First Serve (FCFS)

2. Shortest Job First (SJF)

3. Shortest Remaining Time First (SRTF)

4. Round Robin (RR)

5. Priority Scheduling (PS)


6. Exit

Enter your choice:


1
Enter the total no. of processes:
3
Enter the burst time for each process, starting with the first one
Burst time for Process 0:
12
Burst time for Process 1:
6
Burst time for Process 2:
9
Enter the arrival time for each process, starting with the first one
Arrival time for Process 0:
0
Arrival time for Process 1:
1
Arrival time for Process 2:
4
The data entered is:
Process 0:
Burst Time: 12
Arrival Time: 0

Process 1:
Burst Time: 6
Arrival Time: 1
Process 2:
Burst Time: 9
Arrival Time: 4

The Gantt Chart generated is:


0 12 18 27 Average Waiting Time: 8.333333333333334
Average Turnaround Time: 17.333333333333332
Scheduling Algorithms Menu
==========================

1. First Come First Serve (FCFS)

2. Shortest Job First (SJF)

3. Shortest Remaining Time First (SRTF)

4. Round Robin (RR)

5. Priority Scheduling (PS)

6. Exit

Enter your choice:


2
Enter the total number of processes:
4
Enter the arrival time for process 0:
0
Enter the burst time for process 0:
7
Enter the arrival time for process 1:
2
Enter the burst time for process 1:
4
Enter the arrival time for process 2:
4
Enter the burst time for process 2:
1
Enter the arrival time for process 3:
5
Enter the burst time for process 3:
4

Gantt Chart

0
7
11
12
16

The Average Waiting Time is: 4

The Average Turnaround Time is: 8


Scheduling Algorithms Menu
==========================

1. First Come First Serve (FCFS)

2. Shortest Job First (SJF)


3. Shortest Remaining Time First (SRTF)

4. Round Robin (RR)

5. Priority Scheduling (PS)

6. Exit

Enter your choice:


3

Enter the Total Number of Processes:


4
Enter the arrival time for process 0:
0
Enter the burst time for process 0:
8
Enter the arrival time for process 1:
1
Enter the burst time for process 1:
4
Enter the arrival time for process 2:
2
Enter the burst time for process 2:
9
Enter the arrival time for process 3:
3
Enter the burst time for process 3:
5
Average Waiting Time: 6.5
Average Turnaround Time: 13.0
Scheduling Algorithms Menu
==========================

1. First Come First Serve (FCFS)

2. Shortest Job First (SJF)

3. Shortest Remaining Time First (SRTF)

4. Round Robin (RR)

5. Priority Scheduling (PS)

6. Exit

Enter your choice:


4
Enter the total number of processes:
3
Enter the Burst Time for 0:
24
Enter the Burst Time for 1:
3
Enter the Burst Time for 2:
3
Enter the Time Quantum:
4
Process0:
Burst Time: 24
Waiting Time: 6
Turnaround Time: 30

Process1:
Burst Time: 3
Waiting Time: 4
Turnaround Time: 7

Process2:
Burst Time: 3
Waiting Time: 7
Turnaround Time: 10

Average Waiting Time: 5.6666665


Average Turnaround Time: 15.666667
Scheduling Algorithms Menu
==========================

1. First Come First Serve (FCFS)

2. Shortest Job First (SJF)

3. Shortest Remaining Time First (SRTF)

4. Round Robin (RR)

5. Priority Scheduling (PS)


6. Exit

Enter your choice:


5
Enter the total no. of processes:
5
Enter the burst time for Process 0:
10
Enter the priority of Process 0:
3
Enter the burst time for Process 1:
1
Enter the priority of Process 1:
1
Enter the burst time for Process 2:
2
Enter the priority of Process 2:
4
Enter the burst time for Process 3:
1
Enter the priority of Process 3:
5
Enter the burst time for Process 4:
5
Enter the priority of Process 4:
2
The data entered is:
Process: 0
Burst Time: 10
Priority: 3
Process: 1
Burst Time: 1
Priority: 1

Process: 2
Burst Time: 2
Priority: 4

Process: 3
Burst Time: 1
Priority: 5

Process: 4
Burst Time: 5
Priority: 2

The Gantt Chart generated is:


0 1 6 16 18 19 Average Waiting Time: 8.2
Average Turnaround Time: 12.0
Scheduling Algorithms Menu
==========================

1. First Come First Serve (FCFS)

2. Shortest Job First (SJF)

3. Shortest Remaining Time First (SRTF)

4. Round Robin (RR)


5. Priority Scheduling (PS)

6. Exit

Enter your choice:


6

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