2,613 views
0 0 votes
If the value of a counting semaphore s = 4, then the maximum number of requests for the critical section before it blocks is _____________ ?

1.   0

2.   1

3.   2

4.   4

4 Answers

1 1 vote
Ans is 4

since the counting semaphore will decrease the count for every requesting process until it gets to 0...afterwards it will block the next requesting processes.
1 1 vote
you can apply 4 successful down operation on this semaphore. The next down opeartion will be unsuccessful and the process will get blocked.
0 0 votes

A counting semaphore is a synchronization primitive used in concurrent programming to control access to a resource. The value of a counting semaphore indicates the number of available instances of a resource. When a process wants to access the critical section, it decrements the semaphore value, and when it exits the critical section, it increments the semaphore value.

If the value of the counting semaphore s is 4, it means there are 4 available instances of the resource. Each time a process enters the critical section, it consumes one instance of the resource, and the semaphore value decreases by 1. When the semaphore value reaches 0, it indicates that all instances of the resource are currently in use.

In your case, since the initial value of the semaphore is 4, the maximum number of requests for the critical section that can occur before a process is blocked is also 4. Once 4 processes are in the critical section simultaneously, the semaphore value will become 0, and any additional process wanting to enter the critical section will have to wait until a resource instance becomes available (i.e., another process exits the critical section and increments the semaphore value).

So, the maximum number of requests for the critical section before it blocks is 4.

Position:
Show:

Related questions

2 2 votes
1 1 answer
911
911 views
rsansiya111 asked Dec 8, 2021
911 views
Suppose we want to synchronize two concurrent processes P and Q
1 1 vote
0 0 answers
1.7k
1.7k views
Hirak asked May 9, 2019
1,651 views
2 2 votes
1 1 answer
1.1k
1.1k views
gulsanchouhan asked Oct 14, 2017
1,113 views
1 pointThe variable turn can have values 0 or 1 Void Process (i) { while(1) { //Non-critical section While (turn!=i); //...
1 1 vote
3 3 answers
1.4k
1.4k views
gulsanchouhan asked Oct 13, 2017
1,437 views
State True/False Bakery algorithm ensures that no process is starved.1. True2. False