In this tutorial, we will be discussing a Semaphore and its types ie. Binary, Mutex, Counting.
Later we will see each semaphore in detail with its pros and cons.
Also, we will be looking into priority inversion and priority inheritance.
What is a Semaphore?
Semaphore is a technique for synchronizing two/more task competing for the same resources. When a task wants to use a resource, it requests for the semaphore and will be allocated if the semaphore is available. If the semaphore is not available then the requesting task will go to blocked state till the semaphore becomes free.
Types of Semaphores
There are 3-types of semaphores namely Binary, Counting and Mutex semaphore.
- Binary Semaphore:
- Counnting Semaphore:
- Mutex Semaphore: