⟩ What do you mean by Semaphore and when we will go for using this?
semaphore is used to avoid the effect of dead lock.
there are three types of semaphore .
1)binary semaphore->it is only to acquire and release the
semaphore.zero is used for unavailabel and
one is used for available.
2)counting semaphore->when semaphore is acquired counter is
incremented and when semaphore is released conter is
decremented.when counter is zero it is goes to blocked state.
3)mutual exclusion->it is same as binary semaphore.but it is
used for safty purpose.it is two state locked state and
unlocked state.when semaphore is acquired it is goes to
locked state and when semaphore is released it goes to
unlocked state.