From the course: IoT Foundations: Operating Systems Fundamentals

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Semaphore and mutex

Semaphore and mutex

From the course: IoT Foundations: Operating Systems Fundamentals

Start my 1-month free trial

Semaphore and mutex

- [Narrator] In the operating system, the mutex is your inter-task communication mechanism, which means the mutual exclusion among tasks when they access a shared resource. A mutex can be implemented as a token, when a task seeks to access a resource shared with another one, it has to obtain the token to do so. Let's look at an example to see what it means. Suppose we have Task 1 and Task 2. They attempt to access the shared data, but we know that they cannot do so simultaneously. Or, in other words, there should be mutual exclusion to make sure the shared data can only be accessed or changed by one task at any time. In this case, using the token to allow only the task having the token to access the shared data can make things happen. Task 1 gets the token to access the data, the shared data is locked to Task 1, so no other tasks can access it. When Task 1 is done accessing it, it passes the token to Task 2. Now only Task 2 can access the data. Semaphore is a inter-task communication…

Contents