Computer Science Homework Help

Computer Science Homework Help. calculate pi

I need help with the code;

code requirement:

your program will ask how many iteration to be run, and how many threads to use. and each thread will do the portion of

total iteration.

implement pi program using pthread . multiple threads are to be created.

hint: youtube video to calculate pi via monte carlo

#include <cstdlib>

#include <cmath>

double x = (double)rand()/RAND_MAX;

Help:

(1) a sample program to calculate pi is attached ( see pdf)

(2) an example of thread program ( pic 1&2)

(3) another pthread example, see threadonly.c

(4) code to aggregate result at the end of runner():

pthread_mutex_lock(&mutex_1);

inside += inside_p;

pthread_mutex_unlock(&mutex_1);

notice that you must define the global variables in your program

int inside = 0;

pthread_mutex_t mutex_1;

Computer Science Homework Help

 
"Our Prices Start at $11.99. As Our First Client, Use Coupon Code GET15 to claim 15% Discount This Month!!"