Saturday, 2 June 2018

semaphore

A semaphore is variable with integer value that is updated through 2 standard operations which are atomic :

(1) P: wait () operation
and
(2) V: signal () operation.
Lets say Semaphore variable is Sm

wait(Sm) {
while Sm<= 0 ;    //No-operation, keep in while loop if condition true, next line will not execute
S- - ;       //executed if while loop is not satisfied
}

signal(Sm)
 S+ +;
 }

As both functions are atomic whole wait() and signal() function must be executed without interruption. This means the while condition check and the S- - operation will be executed without break or interruption. Variable Sm can only be accessed by only one function either wait() or signal() at a time.


No comments:

Post a Comment

UGC NET Computer Science December 2019 | Question 16

Question 16 In a certain coding language. 'AEIOU' is written as 'TNHDZ'. Using the same coding language. 'BFJPV' wil...

Popular Posts