Scheduling_Algo_OS_CA

This repository contains SJF non-preemptive scheduling algorithm

View project on GitHub

Scheduling Algorithms

This repository contains SJF preemptive scheduling algorithm and Longest Time Remaining First Alogorithm.

Longest Remaining Time First

Example :-

   0______1______2______3______4______5______6______7______8______9______10_____11_____12_____13_____
   |P2    |P1    |P2    |P4    |P4    |P5    |P4    |P5    |P3    |P4    |P5    |P1    |P2    |P3    |
   |______|______|______|______|______|______|______|______|______|______|______|______|______|______|


   14_____15_____16
   |P4    |P5    |
   |______|______|




    +_______________________________________________________________________________________________+
    |ProcessID      |ArrivalTime    |BurstTime      |CompletionTime |TurnAroundTime |WaitingTime    |
    +_______________________________________________________________________________________________+
    |  1            | 0             | 2             | 12            |  12           | 10            |
    |  2            | 0             | 3             | 13            |  13           | 10            |
    |  3            | 2             | 2             | 14            |  12           | 10            |
    |  4            | 3             | 5             | 15            |  12           | 7             |
    |  5            | 4             | 4             | 16            |  12           | 8             |
    +_______________________________________________________________________________________________+

                            +_____________________________________________+
                            |                Average TAT 12.2             |
                            |                Average WT  9.0              |
                            +_____________________________________________+

Shortest Job First- Premptive

   0______1______2______3______4______5______6______7______8______9______10_____11_____12_____13_____
   |  P1  |  P3  |  P3  |  P3  |  P4  |  P4  |  P4  |  P4  |  P4  |  P4  |  P4  |  P1  |  P1  |  P1  |
   |______|______|______|______|______|______|______|______|______|______|______|______|______|______|


   14_____15_____16_____17_____18_____19_____20_____21_____22_____23_____24_____25_____26_____27_____28_____
   |  P1  |  P1  |  P1  |  P1  |  P1  |  P1  |  P5  |  P5  |  P5  |  P5  |  P5  |  P5  |  P5  |  P5  |  P5  |
   |______|______|______|______|______|______|______|______|______|______|______|______|______|______|______|


   29_____30_____31_____32_____33_____34_____35_____36_____37_____38_____39_____40_____41_____42_____43_____
   |  P5  |  P5  |  P5  |  P2  |  P2  |  P2  |  P2  |  P2  |  P2  |  P2  |  P2  |  P2  |  P2  |  P2  |  P2  |
   |______|______|______|______|______|______|______|______|______|______|______|______|______|______|______|


   44_____45_____46_____47_____48_____49_____50_____51_____52_____53_____54_____55_____56_____57_____58_____
   |  P2  |  P2  |  P2  |  P2  |  P2  |  P2  |  P2  |  P2  |  P2  |  P2  |  P2  |  P2  |  P2  |  P2  |  P2  |
   |______|______|______|______|______|______|______|______|______|______|______|______|______|______|______|


   59_____60_____61
   |  P2  |  P2  |
   |______|______|


    +_______________________________________________________________________________________________+
    |ProcessID      |BurstTime      |ArrivalTime    |CompletionTime |TurnAroundTime |WaitingTime    |
    +_______________________________________________________________________________________________+
    |    1          |    10         |    0          |    20         |    20         |    10         |
    |    2          |    29         |    1          |    61         |    60         |    31         |
    |    3          |    3          |    1          |    4          |    3          |    0          |
    |    4          |    7          |    2          |    11         |    9          |    2          |
    |    5          |    12         |    2          |    32         |    30         |    18         |
    +_______________________________________________________________________________________________+
                            +_____________________________________________+
                            |     The Ending time of Pi(i=4) :  11        |
                            +_____________________________________________+