Line 5: Line 5:
  
 
=What is a Semaphore?=
 
=What is a Semaphore?=
Semaphores are 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 granted 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.
+
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.<br><br>
 +
 
 +
=Types of Semaphores=
 +
There are 3-types of semaphores namely Binary, Counting and Mutex semaphore.
 +
*<b>Binary Semaphore</b>:
 +
 
 +
*<b>Counnting Semaphore</b>:
 +
 
 +
*<b>Mutex Semaphore</b>:

Revision as of 12:08, 12 July 2016

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: