The programs for this lab estimate PI using the Maclaurin series, which is an infinite series approximation typically covered in calculus. The programs compute the estimate by summing the first n terms in the series where n is a command-line argument (along with the number of threads to use). Typically the programs are run like so:
program_name number_threads n
Unless otherwise specified, use n=100000000.
For all these, you need timer.h
Before getting into these programs, let's see how much extra work (overhead) is required to create threads in the first place. To find out:
./pth_do_nothing 1and record the result
These results are consistent with a race condition - the threads are stomping all over each others computations. The next two programs attempt to fix this by establishing and enforcing a critical section.
pth_pi_busy1with 2 threads and n=100000000 terms 3 times. Are the results consistent? How much faster (or slower) is this program than the serial (single-threaded) version?
pth_pi_busy2with 2 threads and n=100000000 terms. How much faster (or slower) is this program than
pth_pi_busy2for 2, 4, and 8 threads, then try 64, 128, and 512 threads. Record the results; label each result with the process count.
pth_pi_busy2, recording runtime and estimate.