693 views

2 Answers

0 0 votes
When you have a resource and multiple processes are permitted to access the resource simultaneously then we set the semaphore value to an integer, this integer value is equal to the number of permitted processes that can simultaneously access the shared resource.
0 0 votes
When we can give access to 'n' processes to share the resource then we can set counting semaphore to an integer 'n' . By giving access one by one to each process we need to decrease the value of counting semaphore. (i.e sometimes it is called as "down" operation or sometimes called as "wait" or sometimes called as "P"). When the value reaches to zero that means CS is full and now if any process comes then decrease the value of counting semaphore and add that process to waiting queue. Now when any process leaves CS, then that waiting process can get access of CS and semaphore value will be increase 1 by 1.

In simple terms, if semaphore value is >= 0 then no processes will  be in the waiting queue.

if value is <0 (i.e -n) then n processes will be in the waiting state.
Position:
Show:

Related questions

3 3 votes
1 1 answer
246
246 views
GO Classes asked Jul 25
246 views
Which of the following statements are correct?Mutual exclusion ensures that if one process is executing in its critical section, no other process can execute in its criti...
2 2 votes
3 3 answers
319
319 views
1 1 vote
2 2 answers
508
508 views
GO Classes asked Dec 29, 2025
508 views
A system uses a modified Counting Semaphore $S$ to manage access to a pool of 3 identical resources. The semaphore is initialized to $S=3$. The $\verb|Wait (S)|$ and $\ve...
0 0 votes
1 1 answer
581
581 views