DEV Community

Shubham Tyagi
Shubham Tyagi

Posted on

Priority Scheduling in operating system

  • Why we need scheduling algorithms ?
    When two or more processes demands the same resource for its processing, how will the CPU decide to which process should the resource be given. So there are many scheduling algorithms which could be used by CPU to decide it.

  • One of which is priority scheduling. Each process is assigned a priority and on the basis of the priority of the process the CPU compare between them. If we have two process with the same priority than it will give the resource to the process which came earlier.

Priority Scheduling

  • The problem with priority scheduling is starvation. It occurs When a process with a much lower priority never gets a chance to be completed. for example there is a process with priority 100 (the higher the value the less its priority) and there is continue occurence of processes with higher priorities than how will it get a chance to be executed.This phenomenon is called starvation. Starvation is different than deadlock.

  • To deal with starvation there is a technique called Aging. So in this technique, we increase the priority of the process after every particular period of time. For example we have a process with priority 100 and we decide to increase it's priority by 1 after every 10 minutes. So in the worst case the process will be executed at priority 0 which it will reach after approximately 17 hours.

Top comments (0)