Question: 2. (30 points) Write a program that uses n threads, where n 1,2, 4, 8 These threads increment a shared variable c. The total number

2. (30 points) Write a program that uses n threads, where n 1,2, 4, 8 These threads increment a shared variable c. The total number of increment operations are m 120, 000. Each thread reads the value of c and increments it m times. Implement the following methods and compare the the total time taken for each of the following methods. Return the final count as c for each of the algorithm. Submit the plot as part of the assignment. (a) Fischer's Algorithm with equal to 10 microseconds. (b) Lamport's Fast Mutex Algorithm. (c) Anderson's Spin Lock Algorithm. 2. (30 points) Write a program that uses n threads, where n 1,2, 4, 8 These threads increment a shared variable c. The total number of increment operations are m 120, 000. Each thread reads the value of c and increments it m times. Implement the following methods and compare the the total time taken for each of the following methods. Return the final count as c for each of the algorithm. Submit the plot as part of the assignment. (a) Fischer's Algorithm with equal to 10 microseconds. (b) Lamport's Fast Mutex Algorithm. (c) Anderson's Spin Lock Algorithm
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
