Question: This formula is used for computing pi ( pi ) , and it takes a lot of terms on the right - hand side before
This formula is used for computing pipi and it takes a lot of terms on the righthand side before
pi value is very accurate. Meaning that the bigger the n the more accurate the pi estimation.
The following serial code uses this formula:
for i ; i n; i
ifi
factor;
else
factor;
sum factori;
pi sum;
Write a multithreaded program by using c that calculates pi using the above formula by dividing the iterations
in the for loop among the threads. To simplify the computations, let's assume that the number of
working threads is and n
After the two working threads split the iterations and each thread has its own local sum, they update
the global variable sum, and the parent thread outputs the sum ie pi estimation once the
workers have exited.
Note that if there is a critical section, you need to protect it from race condition.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
