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. This assignment has an early due date so please don’t delay. If you have questions, be sure to bring them up in section.
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 here in the gzipped archive threads.tgz. Save and extract the tar file (e.g. tar xfz threads.tgz). Enter the directory threads, and the run the script program to generate a log file:
Once you have done this, compile and run the two C++ programs according to the following instructions.
Your first program is a parallel "hello world" program called e1. Open the program with an editor, take a look at the code and at the comments. Compile the program according to the instructions contained in the comments, and and run it. Do the process ID's come in any particular order? Why is this? On some machines, there may be unusual output behavior. If you note such behavior, be sure to comment on it and attempt to offer an explanation
The second program is a slightly different version of the first one and is called e2. As with e1, examine the source code, paying attention to the comments. Compile the program and run it. Do the process ID's come in any particular order? Why is this?
Note that this program takes an optional argument which determines the number of threads to be spawned. Experiment with different values, 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 10 threads.
When you are finished running the two programs, generate output describing your operating system, compiler, and the machine you ran the program by running the following commands
Turn in a text file containing your answers to parts 1 and 2 together with the log file a0.out. Email the two files as attachments to the following address:
| pcicotti | +160_a0 | @ | ucsd. |
edu |
Tutorial on Threads https://computing.llnl.gov/tutorials/pthreads.
Exercises https://computing.llnl.gov/tutorials/pthreads/exercise.html.