in Operating System
1,022 views
0 votes
0 votes
Assume Counting Semaphore N=8.

On performing 10 down() operations by 10 different processes , first 8 will be successful and last two processes will be suspended.

Does this mean that the first 8 processes can enter in the CS at the same time?

In other words, does counting semaphore can let multiple processes access the CS at the same time?
in Operating System
1.0k views

1 comment

Does this mean that the first 8 processes can enter in the CS at the same time?

In other words, does counting semaphore can let multiple processes access the CS at the same time?

yes, Counting semaphores doesn't work for ME. 

If your requirement is ME, then you have to use Binary Semaphores instead of counting semaphore.

1
1

1 Answer

2 votes
2 votes
Best answer

Semaphores are used to coordinate the shared resource access. We can implement semaphores in two different ways. In simple terms, they represent how many resources are available for us to use at a given time. 

  1. Binary semaphore:
    • This is used when we want to implement Mutual Exclusion. 
    • Only one instance of the resource is available thus only one process can enter into the CS at a given time.
    • The values are 0 or 1 for the binary semaphore.
  2. Counting Semaphore:
    • This is used when we have multiple instances of a resource available.
    • The value of counting semaphore is set to the total available resource instances. 
    • Thus allowing multiple processes to use the resource if it's available. 

So if the initial value of counting semaphore is 8 and if we perform 10 down() operations, 

  • First 8 process can access the resource.
  • The remaining 2 process gets blocked. 

 

selected by

Related questions