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. Suppose a thread opened a file for read. Group of answer choices Other threads from...
1. Suppose a thread opened a file for read. Group of answer choices Other threads from another process can also read that file any other thread cannot read that file Other threads within the same process can also read that file any thread within the same process and from another process can also read that file 2. Mutex and semaphores can implement busy wait using two methods: by disabling interrupts or using special atomic instructions (e.g., test_and_set()). Which method is...
      1. Which of the following is true ? A)        semaphores are usually implemented using locks...
      1. Which of the following is true ? A)        semaphores are usually implemented using locks B)        condition variables are associated with monitors C)        both of the above D)        neither of the above        2. The problem with locks is that A)        all processes need to know the key B)        they’re not applicable to more than two processes C)        they use busy-waiting D)        all of the above         3. We can prevent deadlock from occurring by ensuring that the __________...
Linux commands in terminal What processes are running? In the previous task ("Command Based") you were...
Linux commands in terminal What processes are running? In the previous task ("Command Based") you were already familiar with the command "ps" which shows some or all of the processes that are running. When you run "ps", you start a new process and you can see the actual process in the output. Later in this task you will use "ps" more. The "top" command also shows an overview of the processes that exist on the system but it the overview...
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....
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...
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...
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...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT