by Dinesh Thakur Category: Operating System

Definition: Priority Scheduling is a scheduling process which is based on priority. In priority scheduling, the scheduler himself chooses the task priority, and the process which has the highest priority is processed first as compared to other processes.

Example: Shortest Job First (SJF) scheduling

Process Burst Time Priority
P1 7 2
P2 10 5
P3 4 1
P4 2 4
P5 6 3

So now the process are executed on the basis of priority. The GANTT chart for this will be as follows:

Priority scheduling GANTT chart

The average waiting time or AWT= (0+4+11+17+19)/5= 51/5= 10.2 ms

On the Basis of Execution
Priorities are of two types: static and dynamic.
Static priorities are those priorities which we defined while creating the list of processes or you can say that the number of priority does not changes when the process of execution is going on.
Dynamic priorities are those which we defined on the basis of the behavior of the processes or you can say that the priority keeps changing itself when the process of execution is going on as per its own needs.
On the basis of definition
Priorities are further of two types: externally defined and internally defined.
Internally defined priorities are those which make use of any measurable unit so that they can calculate the priority of a process.
Example: time limits, file requirements includes number of open files etc.. and memory requirements etc.
Externally defined priorities are those which make use of some criteria which is beyond our operating system. It includes the sum of resources which are being utilized for computer use, significance of process, user preference and some other factors.
Example: the department which is sponsoring our work, politics, the amount of fund which is being paid for computer use and the type of fund which is being paid for computer use, process importance etc..
On the basis of preemption
It is of two types: preemptive and non-preemptive.
Preemptive priority scheduling algorithm is that which preempts the CPU while executing the process in case high priority process appears in front of the CPU.
Non-preemptive priority scheduling algorithm is that which does not preempts the CPU. It simply puts the new process at the top of the ready queue.

Advantages of Priority Scheduling

• The priority of process is selected on the basis of memory requirement, user preference or the requirement of time.
• Processes are executed on the basis of priority. So high priority does not need to wait for long which saves time.
• It is easy to use.
• It is a user friendly algorithm.
• Simple to understand.
• it has reasonable support for priority.

Disadvantages of Priority Scheduling

• The major disadvantage of priority scheduling is the process of indefinite blocking or starvation. This problem appears when a process is ready to be executed but it has to wait for the long time for execution by CPU because other high priority processes are executed by the CPU.
The problem of starvation can be solved by aging. Aging is a technique in which the system gradually increases the priority of those processes which are waiting in the system from a long time for their execution.
• In case if we have the processes which have the same priority, then we have to make use of 2nd scheduling algorithm.
• If the system get crashes eventually, then all the processes having low priority which are not finished yet, also get lost.

About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.C.A, MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.

Related Articles