Semaphores

Semaphore

Edit

Question :- Write a short note on semaphore with one example    ( 6 marks ) ( May – June 18 )

Ans :- Semaphore is described by Dijkstra. It is a synachronization tool. Semaphore is a non negative integer variable that is used as a flag. Semaphore is an operating system abstract data type. It takes only integer value. Its used to solve critical section problem. Semaphore may be accessed and manipulated through two primitive operations.

a)Wait                   b) Signal

a) Wait :- Dijkstra introduced two operations ( P and V ) to operate on semaphore to solve process synchronization problem. A process calls the P operation when it wants to enter its critical section and calls V operation when it wants to exit its critical section. The P operation is called as wait operation and V operation is called as signal operation.

                A wait operation on a semaphore decrease its value by one.

                Wait : while  S < 0             do  loops ;

S : = S – 1 ;

b) Signal :- The signal operation increments the semaphore value. If the value is < 0, them a process blocked by a wait operation is removed from the waiting queue and sent to ready queue.

                A proper semaphore implementation requires that P and V be indivisible operations A semaphore operation is atomic. This may by possible by taking hardware support. The operation P and V are executed by the operating system in response to calls issued by any one process naming a semaphore as parameter. There is no guarantee that no two processes can execute wait and signal operations on the same semaphore at the same time.

References

Edit
  • WikiNote Foundation

Last modified: Friday, 20 September 2019, 10:21 AM