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...
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...
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 answer the following Case analysis questions 1-How is New Balance performing compared to its primary...
Please answer the following Case analysis questions 1-How is New Balance performing compared to its primary rivals? How will the acquisition of Reebok by Adidas impact the structure of the athletic shoe industry? Is this likely to be favorable or unfavorable for New Balance? 2- What issues does New Balance management need to address? 3-What recommendations would you make to New Balance Management? What does New Balance need to do to continue to be successful? Should management continue to invest...
Sign In INNOVATION Deep Change: How Operational Innovation Can Transform Your Company by Michael Hammer From...
Sign In INNOVATION Deep Change: How Operational Innovation Can Transform Your Company by Michael Hammer From the April 2004 Issue Save Share 8.95 In 1991, Progressive Insurance, an automobile insurer based in Mayfield Village, Ohio, had approximately $1.3 billion in sales. By 2002, that figure had grown to $9.5 billion. What fashionable strategies did Progressive employ to achieve sevenfold growth in just over a decade? Was it positioned in a high-growth industry? Hardly. Auto insurance is a mature, 100-year-old industry...
Discuss ethical issues that can be identified in this case and the mode of managing ethics...
Discuss ethical issues that can be identified in this case and the mode of managing ethics Enron finds itself in this case. How would you describe the ethical culture and levels of trust at Enron? Provide reasons for your assessment. 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...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT