COSC441 Assignment 3, 2017

The purpose of this assignment is to get you to create a very simple threaded program in Erlang.

You are to write a module in Erlang, called a3.erl. It will export a function of two arguments, also called a3. a3(N, T) will compute the square root of the sum of the numbers from 1 to N using T threads. You can call it like this:

% erl
1> c(a3).
2> a3:a3(1000000, 10).

where the first line starts the Erlang shell, the second line compiles and loads the module, and the third line calls the function.

The a3/2 function is to create T threads, each knowing the range of numbers it is to work on. When each thread has finished, it is to send its result back to the original thread. The original thread will receive these rules, add them, and return the square root of the sum.

Submit your assignment within one week by sending an e-mail message to ok@cs.otago.ac.nz with the subject "COSC441 Assignment 3" and just the a3.erl file. Any comments you wish to make should be comments inside that file. Erlang comments begin with "%" and extend to the end of the line.

The purpose of this assignment is to get you writing a little Erlang program. It's not supposed to be a puzzle. So here is a quick reference to some of the things you will need, which is why you should only need one week. Get onto it quickly!