Question: Please solve the extra question. 1) Compile and run the above program as shown then record the output. 2) Add the required lock and unlock
Please solve the extra question.


1) Compile and run the above program as shown then record the output. 2) Add the required lock and unlock statements around the critical section. Re-compile and run the program then record the new results. 3) Explain the difference between both results. Extra: Change the code so each thread can increment the global variable once then pass it to the next thread and so on, the output should be something as the following: tidA 1 tidB 2 tidA 3 tidB 4
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
