Interview Question
Software Engineer / DevelopersRTOS follows priority scheduling , if same priority then round robin .
Now suppose low task is running and has lock L1 . Now lets say High Priority task comes since it priority is high now cpu will given to him
task states (ready running block suspended)
scheduler will select high priority task from ready queque
------------------ Now ---------------------------------------
Low Pri Task-->acquires L1 -->
High Pri Task ->Low pri task goes to ready queue since priority is less ->High Pri try acquiring L1 => goes to block queue state on that lock, later it should go ready state when L1 is unlocked
Please note that Low priority task was in ready queue to be picked up by schdeduler
Now at this time suppose Medium pri task also comes in ready queque.
Now Medium task will be picked up by scheduler since pri is more, this is problem.
One scenario where it is used is pipeline consumption. If in case the high priority thread expects some worked-up variable in low priority state which it will consume and any pre-emption will render the whole solution useless because of inconsistent state that low prioirty thread amy end up with.
en.wikipedia.org:wiki:Priority_inversion
- Raghav June 19, 2011should answer your question.