0
3.3kviews
Explain priority Inversion Problem in Detail?

Subject : Microcontroller and Embedded Programming

Topic : Embedded/Real Time Operating System

Difficulty : Medium

1 Answer
0
149views

Priority inversion problem : If there is a shared resource and the resource is acquired by low priority task, then the higher priority task have to wait for the same, and in case if a medium priority task is being executed , then this is called priority inversion problem i.e. the medium priority task is being executed and the higher priority task has to wait. The priority inversion problem can be solved in two ways:

1. Priority inheritance: In this case the lower priority task is given the priority of the highest task requiring a particular resource and hence not allowing the medium level priority task to preempt.

i. Task 3 is put into running state

ii. Task 3 acquires the mutex

iii. Task 3 starts executing the critical section that requires the mutex

iv. Task 1 preempts task 3

v. Task 1 starts its execution

vi. Task 1 tries to acquire the mutex and hence task 3 is to be executed with the priority same as that of task 1 so that the medium priority task 2 cannot preempt. Task 3 completes the critical task

vii. Task 3 releases the mutex it gains back its original priority

viii. Task 1 completes its critical section and releases the mutex

ix. Task 1 completes its operation and next priority task i.e. task 2 i.e. medium priority task gets into running state the task 3

enter image description here

x. Task 2 completes its execution

xi. Task 3 now gets into running state and gets the cpu time

Fig 11.5 Priority inheritance

2. Priority ceiling: It is same as that of the priority inheritance, only that the lower priority task with semaphore is given the highest priority in the system instead of the priority of the higher task requiring semaphore as in priority inheritance.

Please log in to add an answer.