From the course: IoT Foundations: Operating Systems Fundamentals
Unlock the full course today
Join today to access over 24,200 courses taught by industry experts.
Semaphore and mutex
From the course: IoT Foundations: Operating Systems Fundamentals
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.