You are on page 1of 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