homework-4 Version 0 |
|
👤 Author: by theliyunzealiyuncom 2019-12-09 14:20:22 |
think about your possible case about process synchronization, and give out a solution for the problem.
say a = 10
process a and process b take a and do a -= 5 simultaneously :
p1 = a
p2 = a
p1 = p1 - 5
p2 = p2 - 5
a = p1
a = p2
so variable a is equal to 5 instead of 0 that we want.
solution:
using lock