The purpose of this assignment is to establish a working platform for running pthreads programs, to and to get you thinking about concurrency and its implications. You may run the program on any machine you wish. If you have questions about compiling or running your program, be sure to post to the A2 conference on the web board.
This assignment must be done individually. The reason for this is to establish that each of you has a working platform for developing your code.
This assignment contains 2 parts involving Pthreads code provided to you. The code you need can be found as two C++ programs:
New portable versions of these codes have been posted.Run experiments with each code, and write a report discussing your results and findings. For each experiment, create a script file using the script command so that your output will be saved to a file:
Look over each code, including the comments. Compile using a native C++ compiler, for example with the Gnu C++ compiler (There should be a Gnu g++ compiler on your machine, but use any compiler you wish):
g++ summation.C -lpthread
Experiment with different values of NT, but be sure to run with the following settings:
If you are on a system that you are sharing with others, use care in running with more than 16 threads.
Next, comment out the lock invocations so that the global summation computation is no longer serialized. Did anything change? If you note any anomlous behavior, be sure to comment on it and attempt to offer an explanation
When done with your experiments, close out the script file by typing exit or ^D.
You will now have a file called summation.txtAs before, experiment with differing numbers of threads. This time, use the script command to output to the file sum.txt
When you are finished running the two programs, generate a third script file, config.txt and run the following commands that will produce output describing your operating system, compiler, and the machine you ran the program by running the following commands
Submit a lab report containing a discussion of your experiments and the results, together with the three file summation.txt, sum.txt, and config.txt. Do not transmit the assignment electronically.
Tutorial on Threads https://computing.llnl.gov/tutorials/pthreads.
Exercises https://computing.llnl.gov/tutorials/pthreads/exercise.html.
| Maintained by | baden | @ | ucsd. |
edu | [Thu Oct 2 10:07:12 PDT 2008] |