subject

The pseudocode for a bank account supporting concurrent access. Assume that Lock is a valid locking class, although it is not in Java. Since Lock is not reentrant, the code below is broken. Assuming Lock is not reentrant, Please help me to provide a detailed example where the withdraw method would block forever. Refer to locks using the commented operation number. class BankAccount { private int balance = 0; private Lock lk = new Lock(); int getBalance() { lk. acquire(); // Operation 1 int ans = balance; lk. release(); // Operation 2 return ans; } void setBalance(int x) { lk. acquire(); // Operation 3 balance = x; lk. release(); // Operation 4 } void withdraw(int amount) { lk. acquire(); // Operation 5 int b = getBalance(); if (amount > b) { lk. release(); // Operation 6 throw new (); } setBalance(b - amount); lk. release(); // Operation 7 }}

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 11:10
Which are not examples of chronic or persistent stress? moving
Answers: 1
question
Computers and Technology, 22.06.2019 14:00
Which database model is best used for data warehouse and data mining
Answers: 3
question
Computers and Technology, 23.06.2019 13:50
Explain how email technologies enable the exchange of messages between users. find out the typical parts of an email address and explain each part.
Answers: 1
question
Computers and Technology, 23.06.2019 15:00
Barbara is interested in pursuing a career in the science and math pathway. which qualifications will her reach that goal? a.an advanced knowledge of physics and math b.an advanced knowledge of engineering and math c. an advanced knowledge of physics and robotics an d. advanced knowledge of machinery and math
Answers: 1
You know the right answer?
The pseudocode for a bank account supporting concurrent access. Assume that Lock is a valid locking...
Questions
Questions on the website: 13722359