Question

In: Computer Science

What is the main difference between semaphore and a CV? A semaphore and a lock?

  1. What is the main difference between semaphore and a CV? A semaphore and a lock?

Solutions

Expert Solution

Answer = Both Semaphores and Locks are used to lock the resource to one process to secure system from deadlock condition. Here the main difference between both is that, "Locks have only two states (0 & 1), where 0 is stands for locked resource and 1 is stands for unlocked resources. In locks only one thread can enter in critical section at a time."

But in Semaphores we have multiples states (0,1,2,3,4,...), where 0 is for locked resources and (1,2,3,4,....) is for unlocked resources. here multiple threads can go in critical section, but they can only access unlocked resources.

If one resources is accessed by one processor then that resource is gone in locked condition, means no one can access that resource until processor releases that resource or resource again come in unlocked state.

when a processor uses any resource then it is called in critical section. when a proceesor uses a resource then it called "acquire()" and if it releases a resource then it called "release()".


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?
What is the main difference between notes payable and bonds payable? What is the main difference...
What is the main difference between notes payable and bonds payable? What is the main difference between a bond and a share of stock? What does it mean to issue bonds at Par? Discount? Premium? What is the contract rate and the market rate for bonds? How do you compute total bond interest expense when a bond is sold at a discount? Explain your answer. How do you compute bond interest expense when a bond is sold at a premium?...
What is the main difference between numeric variable and categorical variable; the main difference between ordinal...
What is the main difference between numeric variable and categorical variable; the main difference between ordinal variable and nominal variable; the main difference between ratio variable and interval variable?
What is the main difference between polygene inheritance and heritability?
What is the main difference between polygene inheritance and heritability?
What are the main difference between plant and animal cells?
What are the main difference between plant and animal cells?
a)(5%) Briefly explain the difference between hardness and hardenability.b)(5%) What is the main difference between eutectic,...
a)(5%) Briefly explain the difference between hardness and hardenability.b)(5%) What is the main difference between eutectic, eutectoid and peritectic reactions? c)(10%) A cylindrical piece of 5140 steel heated to γ region and OQ. If the hardness at the surface must be ≥ 35HRC, what is the maximum allowable dia.? Explain.
What is the main difference between the “Protestant Ethic” and the “Spirit of Capitalism”?
What is the main difference between the “Protestant Ethic” and the “Spirit of Capitalism”?
a- What is the main difference between the “net product” of the physiocrats and the concept...
a- What is the main difference between the “net product” of the physiocrats and the concept of value in Smith and Ricardo? b- How did Marx’s times help him develop his own specific labor theory of value? c- How does an individualist (selfish) conception of human nature affect an economic system of thought?
What is bankruptcy? What is the difference between liquidation and reorganization? What is the main benefit...
What is bankruptcy? What is the difference between liquidation and reorganization? What is the main benefit of reorganization?
Q1 what is the definition of knapsack problem ? Q2 what is the main difference between...
Q1 what is the definition of knapsack problem ? Q2 what is the main difference between salesman travelling problem and stagecoach problem ? please give short answer
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT