Question

In: Computer Science

Under what conditions would the use of a counting semaphore initialized to 5 be used instead...

Under what conditions would the use of a counting semaphore initialized to 5 be used instead of a mutex lock?

Solutions

Expert Solution

Semaphore:

Semaphore is nothing but is a special integer variable that can be accessed by only two system calls which are atomic in nature, known as p() and v() or wait() and signal(). It is a signaling mechanism.

The binary semaphore can have two values(0, 1) only

The counting semaphore has an unrestricted domain.

Mutex Lock:

Only one process or task can acquire the mutex lock at a time because ownership is associated with a mutex lock and only the owner can release the mutex lock. It is a locking mechanism.

The binary semaphore can have two values(0, 1) only, so it can be used as a mutex lock.

A binary semaphore is similar to the mutex.   

When a process request for the resource then it performs wait() operation and decrement semaphore value from 1 to 0 and again increment from 0 to 1 when it performs the signal() operation. If the semaphore value is zero and a process requesting for the resource then it will block itself till the current process release the resource.

So, this procedure is similar to the mutex lock.  

But the counting semaphore can not be used as a mutex lock because it has an unrestricted value domain.

The use of a counting semaphore initialized to 5 when there are 5 instances of resources available in the system. Every time when an instance will be assigned to a process the semaphore value will be decreased by one. When the signal() operation will be performed then the semaphore value will be increased by one.


Related Solutions

How is a semaphore initialized when used as a i) a lock() ii) a CV?
How is a semaphore initialized when used as a i) a lock() ii) a CV?
Under what conditions would a seller be willing to sell on consignment? Under what conditions would...
Under what conditions would a seller be willing to sell on consignment? Under what conditions would a seller be willing to sell on terms of cash before delivery? Lastly, Under what conditions would a buyer be comfortable with each of these two extreme terms of sale? (on consignment OR cash before delivery)
What are the various forms of plea bargaining? Under what conditions would each be used?
What are the various forms of plea bargaining? Under what conditions would each be used?
Under what circumstances would we want to use a solvent pair for recrystallization instead of a...
Under what circumstances would we want to use a solvent pair for recrystallization instead of a single solvent? What can cause 'oiling out'?
a. under what conditions would it be appropriate to use a process costing system b. in...
a. under what conditions would it be appropriate to use a process costing system b. in what ways are job order and process costing similar c. Why is accumulation simpler in a process costing than it is in a job order costing system.
Explain why the preparation of nylon-6,10 occurs under milder conditions when decanedioyl dicholride is used instead...
Explain why the preparation of nylon-6,10 occurs under milder conditions when decanedioyl dicholride is used instead of decanedioic acid
Under what conditions would Labor be replaced by Capital? What would be examples of such an...
Under what conditions would Labor be replaced by Capital? What would be examples of such an action? Be specific and provide examples. When does labor replace labor? Under what conditions?  Be specific and provide examples. True or False and why: Companies move to other countries like Mexico and China from the US, because the other countries have cheaper labor costs than in the US. If the MR is greater than MC, then what should a company in the perfect competition industry...
Is it best to use primary data or secondary data? Under what conditions would you tend...
Is it best to use primary data or secondary data? Under what conditions would you tend to use primary data instead of secondary data?
Under what conditions is it necessary to use Monte Carlo analysis in the study of a...
Under what conditions is it necessary to use Monte Carlo analysis in the study of a queuing system?
What is important about the Fair Pricing price and when would it be used instead of...
What is important about the Fair Pricing price and when would it be used instead of the Social Optimal price?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT