Fork me on GitHub

Exercise 1


1. Login to the workshop machine

Workshops differ in how this is done. The instructor will go over this beforehand.

2. Copy the example files

In your home directory, create a pthreads subdirectory for the example codes, copy the example codes and then cd into your pthreads subdirectory:

mkdir pthreads 
cp  /usr/global/docs/training/blaise/pthreads/*   ~/pthreads
cd  pthreads

3. List the contents of your pthreads subdirectory

You should notice a number of files as shown in the tables below.

File Name</span>Description</span>
Data decomposition by loop distribution. Fortran example only works under IBM AIX: see comments in source code for compilation instructions.
condvar.cCondition variable example file. Similar to what was shown in the tutorial
detached.cDemonstrates how to explicitly create pthreads in a detached state.
Mutex variable example using a dot product program. Both a serial and pthreads version of the code are available.
hello.cSimple "Hello World" example
hello32.c"Hello World" pthreads program demonstrating thread scheduling behavior.
hello_arg1.cOne correct way of passing the pthread_create() argument.
hello_arg2.cAnother correct method of passing the pthread_create() argument, this time using a structure to pass multiple arguments.
join.cDemonstrates how to explicitly create pthreads in a joinable state for portability purposes. Also shows how to use the pthread_exit status parameter.
A "series" of programs which demonstrate the progression for a serial dot product code to a hybrid MPI/Pthreads implementation. Files include the serial version, Pthreads version, MPI version, hybrid version and a makefile.

4. Compilers - What’s Available?

5. Create, compile and run a Pthreads “Hello world” program

6. Thread Scheduling

7. Argument Passing

8. Thread Exiting

9. Thread Joining

10. Stack Management