Question: Modify your code for assignment 5 as follows. The main thread should create 5 new threads, which will compute partial values of pi. They will
Modify your code for assignment 5 as follows. The main thread should create 5 new threads, which will compute partial values of pi. They will then update the global sum using pthreads mutex to avoid race conditions. The threads will also compute the time taken for the computation. They will accomplish this by using a pthread barrier at the beginning of the thread and a barrier just after the critical section. Thread 0 will output the time taken. The main thread will output the estimate of pi.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
