CSE 160 Assignment 0
Due Friday, 10/02/08 at 8pm
TO BE DONE INDIVIDUALLY
(5 points)

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:

script a0.out.

Once you have done this, compile and run the two C++ programs according to the following instructions.

Part 1

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

Part 2

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:
1, 4, 7, 10

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

  1. Identify the operating system: uname -a
  2. Identify the machine you ran on: hostname
  3. Identify your compiler and version number: g++ -v (If you aren’t using the Gnu C++ compiler, determine the command needed to generate the version information.
When done running these commands, close the script file by typing exit or ^D.

You will now have a file called a0.out

Things you should turn in

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
Be sure to put the string cse160:A0 in the subject line and to use the email address above; not doing so may result in a penalty.


Useful on-line material on PThreads

Tutorial on Threads https://computing.llnl.gov/tutorials/pthreads.

Exercises https://computing.llnl.gov/tutorials/pthreads/exercise.html.


Tue Sep 30 20:48:08 PDT 2008