Information

Author(s) Erik-Jan Lingen, Matthias Möller
Deadline Καμία προθεσμία
Submission limit No limitation

Συνδεθείτε

[Threads] Exercise 4 : Compute PI

This material is part of the course Practical Introduction to Parallel Programming and meant for educational purposes only.


Task

Modify the program that computes \(\pi\) in parallel from the previous exercise so that it uses a shared variable to keep track of the number of points within a unit circle.

That is, instead of defining a counter per thread, define one shared counter.

Use a mutex to avoid race conditions.

Is this new implementation more efficient than the previous one?


Question 1: Compute PI
Question 2: Command Line Argument

Specify the command line arguments that should be passed to your program when it is run. Arguments must be given in quotes and separated by commas. Leave this filed empty if you do not want to specify command line arguments.

Example: "1","int","arg=2" is interpreted as three arguments 1, int, and arg=2.