Consider the two functions and shown below.
- incr(){ decr(){
- wait(s); wait(s);
- X = X+1; X = X-1;
- signal(s); signal(s);
- } }
There are 5 threads each invoking once, and 3 threads each invoking once, on the same shared variable . The initial value of is
Suppose there are two implementations of the semaphore as follows:
is a binary semaphore initialized to
is a counting semaphore initialized to
Let be the values of at the end of execution of all the threads with implementations respectively.
Which one of the following choices corresponds to the minimum possible values of respectively?