Skip to content

Scheduling algorithms are used in operating systems to manage processes and efficiently allocate resources to them.

Notifications You must be signed in to change notification settings

Rahul-chaurasiya/CPU_Scheduling_Algorithm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

CPU Scheduling Algorithms

Scheduling algorithms are used in operating systems to manage processes and efficiently allocate resources to them.

Input:

Enter the number of Processes: 7

Enter the priority (1 being the highest): 
Enter priority1: 3
Enter priority2: 2
Enter priority3: 4
Enter priority4: 2
Enter priority5: 6
Enter priority6: 5
Enter priority7: 7

Output:

FCFS Scheduling

ALL TIMES ARE IN milliseconds (ms)
+---------------+---------------+---------------+-----------------+-----------------+--------------+
|  Process No.  |  Arrival Time |   Burst Time  | Completion Time | Turnaround Time | Waiting Time |
+---------------+---------------+---------------+-----------------+-----------------+--------------+
|       P6      |       0       |       9       |       9       |       9       |       0       |
|       P4      |       19      |       22      |       41      |       22      |       0       |
|       P3      |       30      |       20      |       61      |       31      |       11      |
|       P7      |       31      |       23      |       84      |       53      |       30      |
|       P2      |       35      |       27      |       111     |       76      |       49      |
|       P5      |       38      |       5       |       116     |       78      |       73      |
|       P1      |       46      |       15      |       131     |       85      |       70      |
+---------------+---------------+---------------+-----------------+-----------------+--------------+

Average Turn around time: 50.57142857142857 milliseconds
Average Waiting time: 33.285714285714285 milliseconds

GANTT CHART


GNATT CHART
__________________________________________________________________________________________________________________________________
|_P6_|___P4___|____P3____|________P7________|____________P2____________|____________P5____________|_____________P1_____________|
0   9       41          61                 84                         111                          116                            131

SJF - Non Premptive scheduling



SJF - Non Premptive scheduling
                ALL TIMES ARE IN milliseconds (ms)
+---------------+---------------+---------------+-----------------+-----------------+--------------+
|  Process No.  |  Arrival Time |   Burst Time  | Completion Time | Turnaround Time | Waiting Time |
+---------------+---------------+---------------+-----------------+-----------------+--------------+
|       P5      |       38      |       5       |       43      |       5       |       0       |
|       P6      |       0       |       9       |       52      |       52      |       43      |
|       P1      |       46      |       15      |       67      |       21      |       6       |
|       P3      |       30      |       20      |       87      |       57      |       37      |
|       P4      |       19      |       22      |       109     |       90      |       68      |
|       P7      |       31      |       23      |       132     |       101     |       78      |
|       P2      |       35      |       27      |       159     |       124     |       97      |
+---------------+---------------+---------------+-----------------+-----------------+--------------+

Average Turn around time: 64.28571428571429 milliseconds
Average Waiting time: 47.0 milliseconds

GANTT CHART

__________________________________________________________________________________________________________________________________________________________________
|P5|________P6________|___P1___|_________P3_________|______________P4______________|________________P7________________|____________________P2____________________|
0 43                 52       67                   87                              109                                 132                                
         159

SJF - Premptive scheduling

                ALL TIMES ARE IN milliseconds (ms)
+---------------+---------------+---------------+-----------------+-----------------+--------------+
|  Process No.  |  Arrival Time |   Burst Time  | Completion Time | Turnaround Time | Waiting Time |
+---------------+---------------+---------------+-----------------+-----------------+--------------+
|       P1      |       46      |       15      |       61      |       15      |       0       |
|       P2      |       35      |       27      |       131     |       96      |       69      |
|       P3      |       30      |       20      |       81      |       51      |       31      |
|       P4      |       19      |       22      |       41      |       22      |       0       |
|       P5      |       38      |       5       |       46      |       8       |       3       |
|       P6      |       0       |       9       |       9       |       9       |       0       |
|       P7      |       31      |       23      |       104     |       73      |       50      |
+---------------+---------------+---------------+-----------------+-----------------+--------------+

Average Turn around time: 39.142857142857146 milliseconds
Average Waiting time: 21.857142857142858 milliseconds

priority - Non-Premptive scheduling

                ALL TIMES ARE IN milliseconds (ms)
+---------------+----------+---------------+---------------+-----------------+-----------------+--------------+
|  Process No.  | priority |  Arrival Time |   Burst Time  | Completion Time | Turnaround Time | Waiting Time |
+---------------+----------+---------------+---------------+-----------------+-----------------+--------------+
|       P6      |    5     |    0       |       9       |       9       |       9       |       0       |
|       P4      |    3     |    19      |       22      |       41      |       22      |       0       |
|       P3      |    1     |    30      |       20      |       61      |       31      |       11      |
|       P7      |    7     |    31      |       23      |       84      |       53      |       30      |
|       P2      |    4     |    35      |       27      |       111     |       76      |       49      |
|       P5      |    6     |    38      |       5       |       116     |       78      |       73      |
|       P1      |    1     |    46      |       15      |       131     |       85      |       70      |
+---------------+----------+---------------+---------------+-----------------+-----------------+--------------+

Average Turn around time: 50.57142857142857 milliseconds
Average Waiting time: 33.285714285714285 milliseconds

GANTT CHART

__________________________________________________________________________________________________________________________________
|_P6_|___P4___|____P3____|________P7________|____________P2____________|____________P5____________|_____________P1_____________|
0   9       41          61                 84                         111                          116                            131

priority - Premptive scheduling

                ALL TIMES ARE IN milliseconds (ms)
+---------------+----------+---------------+---------------+-----------------+-----------------+--------------+
|  Process No.  | priority |  Arrival Time |   Burst Time  | Completion Time | Turnaround Time | Waiting Time |
+---------------+----------+---------------+---------------+-----------------+-----------------+--------------+
|       P1      |    5     |    0       |       9       |       9       |       9       |       0       |
|       P2      |    3     |    19      |       22      |       76      |       57      |       35      |
|       P3      |    1     |    30      |       20      |       50      |       20      |       0       |
|       P4      |    7     |    31      |       23      |       131     |       100     |       77      |
|       P5      |    4     |    35      |       27      |       103     |       68      |       41      |
|       P6      |    6     |    38      |       5       |       108     |       70      |       65      |
|       P7      |    1     |    46      |       15      |       65      |       19      |       4       |
+---------------+----------+---------------+---------------+-----------------+-----------------+--------------+

Average Turn around time: 49.0 milliseconds
Average Waiting time: 31.714285714285715 milliseconds


About

Scheduling algorithms are used in operating systems to manage processes and efficiently allocate resources to them.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages