In the following code, use a lock to protect any data that might need protecting. Keep your critical sections as small as possible. (10%) int flag = 0; int a = 0; void thread_a(){ a += 2; Flag = 1; } 1 void thread_b(){ int b = 0; if (flag) { b++; } b += 3; a -= b; }

Solved
Show answers

Ask an AI advisor a question