Question

What will happen when two processes execute wait() operation on the same semaphore at the same...

What will happen when two processes execute wait() operation on the
same semaphore at the same time and wait() operation is not atomic?
S=1
wait(S)
S){
while (S <= 0)
; // busy wait
S
}
Describe a scenario of context switches where two threads, T 1 and T 2 ,
can both enter a critical section guarded by a single mutex semaphore
as a result of a lack of atomicity.

Homework Answers

Answer #1

Let's say you have 2 threads T1 and T2 and a semaphore with count of 1.

If they both down() at the same time, the atomicity of the primitive guarantees that one will be granted the semaphore and the other one will go to sleep. In particular it is impossible for both to decide to go to sleep OR both acquiring it.

Similarly, down() vs up(). up() will release and wakeup as necessary. In particular it is impossible for the thread doing down() to go to sleep after up() released it.

It's the entire point of the primitive.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
1. Read the case study and draw a process map for the Pit-stop processes. 2. Discuss...
1. Read the case study and draw a process map for the Pit-stop processes. 2. Discuss why organisations should follow the path of the F1 pit crew to improve their process management in their organisations. 3. Discuss how can this Pit-stop process be improved The Fl Pit Stop can be the difference between being first or second on the podium, the difference of winning and losing a season long title, or in fact completing or being out of a race....
1. Summarize in a few sentences what Ayers found about pricing strategies in car markets. 2....
1. Summarize in a few sentences what Ayers found about pricing strategies in car markets. 2. Do you think that this is a profit maximizing strategy? Do you think this is an appropriate and reasonable strategy for businesses to undertake it it increases their profits? 3. Can you think of other goods or services that could be - or are - priced the same way? Check out the article on discrimination in coffee shops "Waiting for Good Joe" for some...
When is a hypothesis considered scientific? a. when it is based on something other than observation...
When is a hypothesis considered scientific? a. when it is based on something other than observation b. when it can be tested and is refutable c. when it relies on anecdotal evidence d. when it relies on mystical explanations e. All hypotheses are considered scientific until experiments determine otherwise. 3. Of the following, which is the earliest step in the scientific process? a. generating a hypothesis b. analyzing data c. conducting an experiment d. drawing a conclusion e. developing a...
What tools could AA leaders have used to increase their awareness of internal and external issues?...
What tools could AA leaders have used to increase their awareness of internal and external issues? ???ALASKA AIRLINES: NAVIGATING CHANGE In the autumn of 2007, Alaska Airlines executives adjourned at the end of a long and stressful day in the midst of a multi-day strategic planning session. Most headed outside to relax, unwind and enjoy a bonfire on the shore of Semiahmoo Spit, outside the meeting venue in Blaine, a seaport town in northwest Washington state. Meanwhile, several members of...
1. The failure of the new supply chain system affected Nike adversely. What were the reasons...
1. The failure of the new supply chain system affected Nike adversely. What were the reasons for the failure and how did the breakdown harm Nike? 2. What are the important elements to be kept in mind while implementing a new system in an organization? What is the importance of a good working relationship between partners and the sharing of responsibility in implementing critical projects? What mistakes did Nike and i2 make? 3. comment on the lessons learned and the...
Review the Robatelli's Pizzeria Case Study. Develop another internal controls system, but this time, in the...
Review the Robatelli's Pizzeria Case Study. Develop another internal controls system, but this time, in the purchases and fixed assets business areas. Prepare a 12- to 16-slide presentation describing the purchases and fixed assets business areas. Be sure to incorporate speaker notes as well as appropriate visuals, graphics, fonts, etc. Include any associated risk in these areas. Describe specific internal controls that include authorization of transactions, segregation of duties, adequate records and documentation, security of assets, and independent checks and...
What role could the governance of ethics have played if it had been in existence in...
What role could the governance of ethics have played if it had been in existence in the organization? Assess the leadership of Enron from an ethical perspective. THE FALL OF ENRON: A STAKEHOLDER FAILURE Once upon a time, there was a gleaming headquarters office tower in Houston, with a giant tilted "£"' in front, slowly revolving in the Texas sun. The Enron Corporation, which once ranked among the top Fortune 500 companies, collapsed in 2001 under a mountain of debt...
Using the model proposed by Lafley and Charan, analyze how Apigee was able to drive innovation....
Using the model proposed by Lafley and Charan, analyze how Apigee was able to drive innovation. case:    W17400 APIGEE: PEOPLE MANAGEMENT PRACTICES AND THE CHALLENGE OF GROWTH Ranjeet Nambudiri, S. Ramnarayan, and Catherine Xavier wrote this case solely to provide material for class discussion. The authors do not intend to illustrate either effective or ineffective handling of a managerial situation. The authors may have disguised certain names and other identifying information to protect confidentiality. This publication may not be...
The Business Case for Agility “The battle is not always to the strongest, nor the race...
The Business Case for Agility “The battle is not always to the strongest, nor the race to the swiftest, but that’s the way to bet ’em!”  —C. Morgan Cofer In This Chapter This chapter discusses the business case for Agility, presenting six benefits for teams and the enterprise. It also describes a financial model that shows why incremental development works. Takeaways Agility is not just about the team. There are product-management, project-management, and technical issues beyond the team’s control. Lean-Agile provides...
Please read the article and answear about questions. Determining the Value of the Business After you...
Please read the article and answear about questions. Determining the Value of the Business After you have completed a thorough and exacting investigation, you need to analyze all the infor- mation you have gathered. This is the time to consult with your business, financial, and legal advis- ers to arrive at an estimate of the value of the business. Outside advisers are impartial and are more likely to see the bad things about the business than are you. You should...