In this assignment you will modify your Assignment 3 so that the programs use correct synchronization.
Create new directories for this assignment. Make sure you keep a copy of your Assignment 3 code.
Part 1:
Copy all of your programs from Part 1 of Assignment 3
into a new directory. Modify the programs so that they are correct.
Use mutexes from the pthreads library to protect the critical sections.
Do this in such a way that there is as much parallelism as possible.
Think about how many mutexes you want to use. For this part of the
assignment assume that the calls to the mutex function do not produce errors.
Do some timing tests and compare the times for Part 1 of Assignment 3 and Part 1 of this assignment. Be sure to run the tests on the same machine. If you choose parameters that make the programs run for a few seconds, you can use the shell's time command to do the timing. We are interested in wall clock time. Alternatively, you can do the timing with gettimeofday. See USP, Chapter 9.
At the top of each output page, describe the machine that you ran on. State the architecture (PC, MAX, SPARC, etc), the operating system, and the number of CPUs. All of the machines in our labs have a single CPU. For each run, it should be clear what the command line parameters are. Always display the total count of the number of iterations actually done. This is the denominator used for calculating the average.
Discuss the results.
Part 2:
Copy the programs from Part 1 into a new directory and modify them so that
an error in one of the mutex functions is eventually discovered.
If any errors occur, the entire calculation is suspect. If any errors occur,
print a message indicating that there was an error and do not display the
results of the calculations. Try to do this in a way that is most
efficient when no errors occur. However, you should only exit the program
from the original main function, not from the threads.
Do some timing tests and determine the
amount of overhead you added by doing the error checking.
Be sure the output is appropriately labeled as in Part 1.
Discuss the results.
Part 3:
Copy all of your programs from Part 3 of Assignment 3
into a new directory. Modify the programs so that they are correct.
Make sure you understand how Java synchronization works. There is not much
that needs to be changed, but be sure to do it correctly.
Do some timing tests and compare the times for Part 3 of Assignment 3 and Part 3 of this assignment. Be sure to run the tests on the same machine. Choose parameters that make the programs run for a few seconds. Label the output as in Part 1. If the programs run long enough, you can use wall clock time. Otherwise, use System.nanoTime.
Discuss the results.
Handing in your assignment
Use this cover sheet.