

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Due Date: 11:59 pm, Friday July 27th^ , 2007.
A thread is an independent stream of instructions that is meant to execute in parallel with other independent streams of instructions. Up until now, you have probably only written single threaded programs. This means that within your program, there is only one code segment executing (serially) at any given time. With multithreaded applications, there can be multiple code segments executing.
The concept of multithreading should not be new to you. When ever you open a web browser, type in www.google.com, and hit enter you are dealing with multiple threads. One thread is contacting the web server for www.google.com while another thread is waiting for you to press a button so that it can process your input. If your web browser was not multithreaded, you would not be able to interact with it while it was trying to load a web page.
There are two components to this assignment ā a warm-up component designed to help you become familiar with multithreaded programming and a component where you will introduce synchronization of threads to the program.
Use one of the Solaris or Linux machines in Klaus 1448. If you want to remote connect and need help, see the TA at office hours.
The BlackāScholes model is a mathematical model of the market for an equity, in which the equity's price is a stochastic process. The BlackāScholes PDE is an equation which (in the model) must be satisfied by the price of a derivative on the equity. The course website provides links to both the single threaded version and multi-threaded version of Black-Scholes.
Observe the performance difference between single and multi-threaded programs. Now increase the number of threads in the multi-threaded version (change the Num-Threads definition). Plot the execution time vs. number of threads. Briefly explain the behavior that is captured in the plots.
In this section you will extend the Black-Scholes multi-threaded program to include synchronization of data accesses. The goal is to have many threads executing at one time. This can only achieved by using locks to control the access to shared data.
In the current Black-Scholes program there are a set of threads created and each thread is given separate arguments to execute code. This should be modified so that there is one main that initializes the thread_data_array where each element can be thought of as āa piece of workā. Then an arbitrary amount of āworkerā threads are created. These threads will check the thread_data_array for an available āpiece of workā that hasnāt been allocated. The thread will mark this element as allocated, execute the Black-Scholes model on the data stored in this element, and write the result back to this element in the thread array. It is the accesses to the thread array that must be synchronized across threads since multiple threads may be trying to access the array concurrently.
Structure of the program:
The tutorial links at the bottom of the page has examples of using functions from the pthread library, mutex and condition variables. They have many helpful examples that are worthwhile to go through before starting to code.