During this activity, students should be able to:
This activity helps the student develop the following skills, values and attitudes: ability to analyze and synthesize, capacity for identifying and solving problems, and efficient use of computer systems.
Individually, solve the following set of concurrent
programming exercises using Erlang. Place all your functions in a module
called procs
.
The function called double
starts two processes and
sends a message M times forwards and backwards between
them. After all the messages have been sent the processes should
terminate gracefully.
The output of the function should look something similar to the following (M = 5):
> procs:double(5). Created <0.33.0> Created <0.34.0> <0.33.0> received message 1/5. <0.34.0> received message 1/5. <0.33.0> received message 2/5. <0.34.0> received message 2/5. <0.33.0> received message 3/5. <0.34.0> received message 3/5. <0.33.0> received message 4/5. <0.34.0> received message 4/5. <0.33.0> received message 5/5. <0.33.0> finished <0.34.0> received message 5/5. <0.34.0> finished
The function called ring
starts N
processes, and sends a message M times around all the
processes in the ring. After all the messages have been sent the
processes should terminate gracefully.
The output of the function should look something similar to the following (N = 3, M = 4):
> procs:ring(3, 4). Current process is <0.31.0> Created <0.33.0> Created <0.34.0> Created <0.35.0> <0.33.0> received 1/4 from <0.31.0> <0.34.0> received 1/4 from <0.33.0> <0.35.0> received 1/4 from <0.34.0> <0.33.0> received 2/4 from <0.35.0> <0.34.0> received 2/4 from <0.33.0> <0.35.0> received 2/4 from <0.34.0> <0.33.0> received 3/4 from <0.35.0> <0.34.0> received 3/4 from <0.33.0> <0.35.0> received 3/4 from <0.34.0> <0.33.0> received 4/4 from <0.35.0> <0.33.0> finished <0.34.0> received 4/4 from <0.33.0> <0.34.0> finished <0.35.0> received 4/4 from <0.34.0> <0.35.0> finished
The function called star
starts N + 1
processes in a star, and sends a message M times
forwards and backwards between the center process and the other
processes. After all the messages have been sent the processes
should terminate gracefully.
The output of the function should look something similar to the following (N = 3, M = 4):
> procs:star(3, 4). Current process is <0.31.0> Created <0.33.0> (center) Created <0.34.0> Created <0.35.0> Created <0.36.0> <0.33.0> received 0/4 from <0.31.0> <0.34.0> received 1/4 from <0.33.0> <0.33.0> received 1/4 from <0.34.0> <0.35.0> received 1/4 from <0.33.0> <0.33.0> received 1/4 from <0.35.0> <0.36.0> received 1/4 from <0.33.0> <0.33.0> received 1/4 from <0.36.0> <0.34.0> received 2/4 from <0.33.0> <0.33.0> received 2/4 from <0.34.0> <0.35.0> received 2/4 from <0.33.0> <0.33.0> received 2/4 from <0.35.0> <0.36.0> received 2/4 from <0.33.0> <0.33.0> received 2/4 from <0.36.0> <0.34.0> received 3/4 from <0.33.0> <0.33.0> received 3/4 from <0.34.0> <0.35.0> received 3/4 from <0.33.0> <0.33.0> received 3/4 from <0.35.0> <0.36.0> received 3/4 from <0.33.0> <0.33.0> received 3/4 from <0.36.0> <0.34.0> received 4/4 from <0.33.0> <0.34.0> finished <0.33.0> received 4/4 from <0.34.0> <0.35.0> received 4/4 from <0.33.0> <0.35.0> finished <0.33.0> received 4/4 from <0.35.0> <0.36.0> received 4/4 from <0.33.0> <0.36.0> finished <0.33.0> received 4/4 from <0.36.0> <0.33.0> finished
Using the Online
Assignment Delivery System (SETA), deliver the file called
procs.erl
. No assignments will be accepted through
e-mail or any other means.
IMPORTANT: The program source file must include at the top the author's personal information (name and student id) within comments. For example:
%% ITESM CEM, October 13, 2009. %% Erlang Source File %% Activity: Concurrent Programming %% Author: Steve Rogers, 449999 . . (The rest of the program goes here) .
Due date: Tuesday, October 13.
This activity will be evaluated using the following criteria:
-10 | The program doesn't contain within comments the author's personal information. |
---|---|
10 | The program contains syntax errors. |
DA | The program was plagiarized. |
10-100 | Depending on the amount of exercises that were solved correctly. |