Open In App

Priority Assignment to Tasks in Operating System

Assigning priority to tasks :
When the number of tasks with different relative deadlines are more than the priority levels supported by the operating system, then some tasks share the same priority value. But the exact method of assigning priorities to tasks can proficiently affect the utilization of processor.

If the tasks are randomly selected for sharing the same priority level then the utilization of the processor would be lessen. It is required to select the tasks systematically to share a priority level so that the achievable schedulable utilization would be higher.

There are several priority assignment methods used when tasks share the same priority level. Some of the most used methods are:

1. Uniform Priority Assignment :
In this assignment method, all the tasks are uniformly divided among the available priority levels. If the number of priority levels completely divides the number of tasks then uniform division tasks among priority levels can be done easily.

For example, if there are 20 tasks to be scheduled and 4 priority levels are supported by the operating system then each priority level is assigned 5 tasks.
If uniform division is not possible i.e there are N tasks and p priority levels and N % p > 0 then floor(N/p) tasks are assigned to each level and remaining tasks are assigned to lower priority levels.

For example, if there are 10 tasks to be scheduled and 4 priority levels are supported by the operating system then firstly floor(10/4) i.e. 2 tasks are assigned to each priority levels and remaining 2 tasks are assigned to one each to lower priority levels.

2. Arithmetic Priority Assignment :
In this assignment method, an arithmetic progression is formed by the number of tasks assigned to each priority level.

For example,
If N are number of tasks and p is number of priority levels then

N = a + 2a + 3a + 4a + ... + pa 

where ‘a’ tasks are assigned to highest priority level,
‘2a’ tasks are assigned to next highest priority level and so on.

3. Geometric Priority Assignment :
In this assignment method, a geometric progression is formed by the number of tasks assigned to each priority level.

For example,
If N are number of tasks and p is number of priority levels then

N = a + a^2 + a^3 + a^4 + ... + a^p 

where ‘a’ tasks are assigned to highest priority level,
‘a^2’ tasks are assigned to next highest priority level and so on.

3. Logarithmic Priority Assignment :
In this assignment method, shorter period tasks are allotted distinct priority levels as much as possible and lower priority tasks (tasks with higher period) are combined together and assigned to same priority level so that higher priority tasks would not be affected. For this the tasks are arranged in increasing order of their period.

If pmax is the maximum period and pmin is the minimum period among period of all tasks and p is the number of priority levels then,

k = (pmax/pmin )^(1/p) is calculated, 

and tasks with periods up to k are assigned to highest priority, tasks with periods from k to k^2 are assigned to next highest priority, tasks with periods from k^2 to k^3 are assigned to next highest priority and so on.

Article Tags :