Semaphores proposed by Etzker Dystra are a technique to manage concurrent processes by
using a simple integer value which is known as a semaphore. Semaphores are a shared
variable and this variable will be used to solve the critical section problem and to achieve
process synchronization in the multiprocessing environment. Semaphores can be accessed by
processes through only two standard atomic operations which are weight and signal. Processes
use p to denote the weight operation and v to denote the signal operation. The weight operation
is denoted using p and v so where did this come from this is what we just saw they came from
these dutch words so when the semaphore's needs to be accessed by a process what happens
is it will check whether the variable s is less than or equal to zero. There are two types of
semaphores which we'll be discussing so based on those two kinds of sum of fours when we
explain it this will become clearer all right so remember that this weight operation is used to test
if there is any other process using the resource or if any other. If process is there in the critical
section and it is not there it will decrement the value of s.
All the modifications to the integer value of the semaphore in the weight and signal operations
must be executed indivisibly, which means that when one process modifies a value no other
processors can simultaneously modify that same value. The value of a binary semaphores can
range only between 0 and 1, so if the value is zero that means the shared resource is being
used by some other process and the currently requesting process has to wait. If the value of the
semaphore is 1, then it is free for the currently requesting process to either enter its critical
section or to use the shared resource that it wants to use. The value of sum of four will initially
be initialized to the value one, so one will be the initial value of a process. The process that
wants to currently execute in the critical section is free to do so. When s is equal to zero, what
happens? That process will not be able to enter its critical section or access the shared
resource that it wants to use, so it gets stuck there. The value of s is now one, which means that
this process is signaling other processes that I have completed using the critical section of
shared resource. Whatever it may be.
Counting semaphores are used to control access to resources that have multiple instances. It is
limited the resource will not have indefinite or infinite instances so in that way if there are
multiple instances of a particular resource then multiple processes can make use of it but again
it is limited. The counting semaphore works it is not just ranging between 0 and 1 but it will have
a range within an unrestricted domain. One process trying to use it which was stuck in this loop
so when process p1 increments is value of s what will happen this condition will now become
false. In binary semaphores we saw how it can be used to achieve mutual exclusion and in
counting sum of force we saw that how it also can also be used for accessing multiple instances
of resources. As long as resources are available the processes will be able to use them but
once they are not available once we have run out of resources then the other processors will be
unable to access that particular resource and will be stuck in this loop.
using a simple integer value which is known as a semaphore. Semaphores are a shared
variable and this variable will be used to solve the critical section problem and to achieve
process synchronization in the multiprocessing environment. Semaphores can be accessed by
processes through only two standard atomic operations which are weight and signal. Processes
use p to denote the weight operation and v to denote the signal operation. The weight operation
is denoted using p and v so where did this come from this is what we just saw they came from
these dutch words so when the semaphore's needs to be accessed by a process what happens
is it will check whether the variable s is less than or equal to zero. There are two types of
semaphores which we'll be discussing so based on those two kinds of sum of fours when we
explain it this will become clearer all right so remember that this weight operation is used to test
if there is any other process using the resource or if any other. If process is there in the critical
section and it is not there it will decrement the value of s.
All the modifications to the integer value of the semaphore in the weight and signal operations
must be executed indivisibly, which means that when one process modifies a value no other
processors can simultaneously modify that same value. The value of a binary semaphores can
range only between 0 and 1, so if the value is zero that means the shared resource is being
used by some other process and the currently requesting process has to wait. If the value of the
semaphore is 1, then it is free for the currently requesting process to either enter its critical
section or to use the shared resource that it wants to use. The value of sum of four will initially
be initialized to the value one, so one will be the initial value of a process. The process that
wants to currently execute in the critical section is free to do so. When s is equal to zero, what
happens? That process will not be able to enter its critical section or access the shared
resource that it wants to use, so it gets stuck there. The value of s is now one, which means that
this process is signaling other processes that I have completed using the critical section of
shared resource. Whatever it may be.
Counting semaphores are used to control access to resources that have multiple instances. It is
limited the resource will not have indefinite or infinite instances so in that way if there are
multiple instances of a particular resource then multiple processes can make use of it but again
it is limited. The counting semaphore works it is not just ranging between 0 and 1 but it will have
a range within an unrestricted domain. One process trying to use it which was stuck in this loop
so when process p1 increments is value of s what will happen this condition will now become
false. In binary semaphores we saw how it can be used to achieve mutual exclusion and in
counting sum of force we saw that how it also can also be used for accessing multiple instances
of resources. As long as resources are available the processes will be able to use them but
once they are not available once we have run out of resources then the other processors will be
unable to access that particular resource and will be stuck in this loop.