Priority inversion is a nasty concurrency bug that occurs when a low priority thread prevents a high priority thread from running. In a sense, the priority structure has been “inverted,” as the low priority thread gets to run first.
The code for the challenge, which starts with unbounded priority inversion, can be found here: [ Ссылка ]
The solution to the challenge can be found here: [ Ссылка ]
Code for this video series (including demonstrations, challenges, and solutions) can be found here: [ Ссылка ]
Bounded priority inversion happens in the simple case where a high priority task takes a lock (e.g. mutex or semaphore) and prevents a high priority task from running, as the high priority task is blocked waiting for the same lock. We consider this “bounded” because the blocking is bounded by the length of time the low priority task is executing inside the critical section (prior to returning the lock).
Preventing bounded priority inversion requires careful thinking about how the threads interact and either limiting or avoiding critical sections. One possible solution is to create a task (or thread) that manages a shared resource. All other threads must use queues (or other synchronization techniques) to send and receive data from this task.
Unbounded priority inversion occurs when a medium priority task preempts a low priority task that’s holding a lock needed by a high priority task. It’s “unbounded” because the amount of time that the high priority task is blocked is dependent on the time the medium task runs without yielding to the low priority task (which needs to release the lock).
We can prevent unbounded priority inversion through the use of the priority ceiling protocol or priority inheritance, which we cover in the video. Both techniques require that the priorities of tasks can be dynamically changed at runtime. Note that both techniques do not prevent bounded priority inversion.
Product Links:
[ Ссылка ]
Related Videos:
Introduction to RTOS Part 1 - What is a Real-Time Operating System (RTOS)? - [ Ссылка ]
Introduction to RTOS Part 2 - Getting Started with FreeRTOS - [ Ссылка ]
Introduction to RTOS Part 3 - Task Scheduling - [ Ссылка ]
Introduction to RTOS Part 4 - Memory Management - [ Ссылка ]
Introduction to RTOS Part 5 - Queue - [ Ссылка ]
Introduction to RTOS Part 6 - Mutex - [ Ссылка ]
Introduction to RTOS Part 7 - [ Ссылка ]
Introduction to RTOS Part 8 - [ Ссылка ]
Introduction to RTOS Part 9 - [ Ссылка ]
Introduction to RTOS Part 10 - [ Ссылка ]
Introduction to RTOS Part 11 - [ Ссылка ]
Introduction to RTOS Part 12 - [ Ссылка ]
Related Project Links:
[ Ссылка ]
Related Articles:
[ Ссылка ]
Learn more:
Maker.io - [ Ссылка ]
Digi-Key’s Blog – TheCircuit [ Ссылка ]
Connect with Digi-Key on Facebook [ Ссылка ]
And follow us on Twitter [ Ссылка ]
![](https://s2.save4k.ru/pic/C2xKhxROmhA/maxresdefault.jpg)