A shared counter is 6. In a non-atomic trace, both threads read 6 and calculate 7; A stores 7, then B stores 7. Why is an increment lost?
In the lesson's non-atomic model, how does a thread increment a shared counter from 3?
What is a critical section in this lesson?
Every conflicting balance update uses the same lock. Where should one update acquire and release it to prevent a lost update?
In a non-atomic teaching trace, balance starts at 20. A and B each read 20, add 3 locally, then store. A stores first and B stores second. What is the final balance?
Answer: ______________
To protect one balance update, a thread must keep the balance lock while doing unrelated printing that does not access the balance.
Circle one: True False
If every thread changing a stock count uses the same lock, holding that lock across checking stock and taking an item prevents another such thread from changing stock between those two steps.
Circle one: True False
Balance is 12. A checks balance >= 10. B then withdraws 5, leaving 7. A uses its earlier check and withdraws 10, leaving -3. No shared lock protects the check and withdrawal. What caused the negative result?