Computers and Technology
Computers and Technology, 19.03.2020 18:26, zeezee46

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 }}

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 07:30, DivineMemes420
What type of computer network ensures high security ?
Answers: 1
image
Computers and Technology, 22.06.2019 12:30, kayleigh2037
What characteristic of long period comets suggest they come directly from the oort cloud?
Answers: 2
image
Computers and Technology, 23.06.2019 03:30, patience233
Many everyday occurrences can be represented as a binary bit. for example, a door is open or closed, the stove is on or off, and the fog is asleep or awake. could relationships be represented as a binary value? give example.
Answers: 1
image
Computers and Technology, 23.06.2019 12:40, melaniem50
Curriculum exam to process a resident's payment, you must click on onesite payments home page. from the a. reports b. my settings o c. transactions o d. rent tab
Answers: 1
Do you know the correct answer?
The pseudocode for a bank account supporting concurrent access. Assume that Lock is a valid locking...

Questions in other subjects: