Worksheet 2
CS599, Parallel Programming and Algorithms
Introduction to Linux and Command Line Compilation

This worksheet is based upon examples from the LLNL OpenMP site and examples from the 44-550, Operating Systems course. The purpose of this lesson is to continue learning about command line compilers, multi-threaded programming, and the Linux Operating System.

You should use the LittleFe system to complete this worksheet. Follow the instructions on the class website to login to either littlefe.nwmissouri.edu or littlefe2.nwmissouri.edu using the secure shell protocol (ssh). 

This worksheet includes both reading material and exercises. Statements such as "Enter the following command..." or "Type..." denote that you should type an appropriate response at the command line to get a response from the operating system. UNIX commands will be in bold font. Write answers in the spaces provided.

Obtain the race condition examples and the matrix add example from the course examples page. Links to these examples are also provided here for your reference - Threaded Matrix Addition Example, Broken Race Condition Example, and Fixed Race Condition Example

Copy these files onto one of the LittleFe systems.

Compile and run each of these files using the gcc compiler with the following format.

gcc sourceFile.c -pthread -o executableFile.exe

Next, run each of the programs

Do you notice any difference between the results from the race condition examples?

If not, run the broken race condition example several times to see what happens.

Next, work to convert each of the examples from pthreads to OpenMP.

For all of the examples, this will involve writing a serial version of the program using #pragma statements.

In class, the instructor will walk through examples of each with you, indicating how to use the shared, private, and critical directives in OpenMP.