Day 64 - Scheduling and Scheduling Algorithms [1]

This is the second post about Scheduling Algorithms and in the last post I wrote about two of them which were First-Come First-Serve and Shortest Job First Scheduling. and in this post I will be going over remaing four of the Scheduling Algorithms.

Priority Scheduling

This scheduling algorithm picks the jobs based on the highest priorit means that the jobs to be processed must have a priority associated with it before it can be processed. The priority is defined with an integer like between 1 and 10 and the CPU is allocated to the process with the highest priority in the queue. In some systems 1 can mean the higest priority or it can mean the lowest priority depending on how it is implemented.

| Name | Time | Priority |
| P1   | 10   | 3        |
| P2   | 1    | 1        |
| P3   | 5    | 2        |

// By this P2 will be processed first instead of P1
// and after that P3 and P1 will be the last one
// to be processed

Round Robin Scheduling

Another way to schedule the jobs is to assign a small amount of time to each process to execute it and after that time is up stop that and process and get to the next one. This way all the porcesses are getting equal amount of time and the processes which are shorter in run time will execute first and the processes that are longer in run time will take more time to complete. This small time is called Time Quantum or Time Slice.

| Name | Time |
| P1   | 24   |
| P2   | 3    |
| P3   | 3    |

let timeSlice = 4;

// These tasks will run in following time until all
// the tasks are completed
| P1 | P2 | P3 | P1 | P1 | P1 | P1 | P1 |
0    4    7    10   14   18   22   26   30

I think these are enough for now as I will be leaving this Data-Strcutures and Algorithms Series for the moment and will focus on learning about the OS from tomorrown because that is what I will be learning at college.


zainscizainsci