A mutex, brief for MUTual EXclusion, is a securing device that is utilized to avoid various other threads from overwriting a section or disturbing of common data (such as a worldwide variable or common buffer).
The service to the obstacle in the video clip can be discovered below: https://www.digikey.com/en/maker/projects/introduction-to-rtos-solution-to-part-6-freertos-mutex-example/c6e3581aa2204f1380e83a9b4c3807a6
Code for this video series (including presentations, services, and also obstacles) can be discovered here: https://github.com/ShawnHymel/introduction-to-rtos
FreeRTOS executes mutexes as well as semaphores with lines, and also operations to review, increment, as well as decrement these kernel objects are all atomic (indicating various other threads can not disturb or customize the variables during those operations).
We make use of a mutex as a securing system to protect a shared source or critical area of code. When a thread or job takes a mutex, the value of the mutex is decremented from 1 to 0, as well as other jobs might not take the mutex while it is 0.
When the task is done working in the essential section, it provides the mutex back, which increments it from 0 to 1. This activity of offering a mutex and also taking permits just one thread to run in a critical section of code each time (it is mutually unique: nothing else strings may perform that section or take the mutex throughout that time).
In the video, we offer an instance of a race problem and also just how a mutex can be utilized to stop it from happening. We offer a demonstration of making use of a mutex in FreeRTOS and afterwards provide a difficulty to use a mutex to allow specifications to be passed to jobs (note: this is a hack!).
Introduction to RTOS Part 1 – What is a Real-Time Operating System (RTOS)? – https://youtu.be/F321087yYy4
Intro to RTOS Part 2 – Getting Started with FreeRTOS – https://youtu.be/JIr7Xm_riRs
Intro to RTOS Part 3 – Task Scheduling – https://youtu.be/95yUbClyf3E
Intro to RTOS Part 4 – Memory Management – https://youtu.be/Qske3yZRW5I
Introduction to RTOS Part 5 – Queue – https://youtu.be/pHJ3lxOoWeI
Discover a lot more:
Maker.io – https://www.digikey.com/en/maker
Digi-Key’s Blog– TheCircuit https://www.digikey.com/en/blog
Get in touch with Digi-Key on Facebook https://www.facebook.com/digikey.electronics/
As well as follow us on Twitter https://twitter.com/digikey