CMPS-4350 Lab 11

Multithreading

Your objective for this lab is to implement multithreading into a program to help its performance

You can freely talk with each other in order to come up with a solution, but you each need to write your own code.

You will need to run this program on your local machine to see changes in performance.

from your local machine use sftp to retrieve files. type "sftp (username)@odin" and enter your password. From there type the following command:

get /home/stu/ebarajas/public_html/4350/b/*


Notes That may be needed for the lab


Task - get the program running with multiple threads
the cpp program provided will currently run and will diplay the current fps the program is running at.
I have set it up where if you press the "A" key, it will switch over to run on multiple threads instead.

However, at the current state of the program if you press the "A" key the program will freeze (go ahead and try it if you want) from having the main thread wait for waiting threads to finish, this is referred to as a "Deadlock".
your task is to use what you have learned from your instructor for the day (or your own knowledge of multithreading) to fix this deadlock and synchronize the main thread with the other threads to keep any other deadlocks from happening.

if you are successful you should see a change in performance when switching between a single thread and multiple threads.

*There will be comments in the cpp file to help you with finishing your task.
**All work will be done in the "main" function, but feel free to look at the rest of the code if you would like.


When finished with the lab
Go ahead and mess with the values of the number of particles in your program and the number of threads that will handle them.
I have set it up where you can change how many particles can be on the screen at once and how many threads will handle the particles by changing a few values at the top of the cpp file, see what values get you the highest performance.

try adding a VERY high number of threads (for my local machine at home, it had to be 8000) does the fps of the program higher or lower? how come? (your instructor for the day can tell you if you'd like).

if your good with opengl and physics and what not and you understand how the program works, go ahead and mess around with the animation itself, add more conditional statements (or just make it look cool) and see how the performance 
is impacted with multithreading.


What to turn in?
lab11.cpp in your /4350/b/* directory.
Thank you for taking the time to work on this assignment.