What is priority inversion, how to solve it?
Anonymous
Priority inversion is a situation where a low priority process blocks a high priority process from running on the CPU. Suppose there are three tasks with low, medium and high priorities, the low and high task share a common resource between them. So currently assume that a low priority process is running on the CPU and it's about to enter its critical section so it obtains a mutex before its critical section but is pre-empted by a medium task and the medium task is running. After some time high task preempts a medium task and is now running on the CPU, and while its running needs the shared resource which was taken by the low task before being pre-empted. So now high task needs to wait for the resource so it gets into a wait queue of the mutex, meanwhile, the medium process starts running finishes its task and then low task runs and releases the mutex and the high task runs. In this situation, the high task had to wait for a low task which is not expected behavior. This is priority inversion. Solution: Let the low task take the priority of high task until it finishes its critical region.
Check out your Company Bowl for anonymous work chats.