CS 4960-01 Homework 2

Due: Monday, September 8th, 2008 10:45am

Submit two programs (server and client) on a CADE machine using

handin cs4960-01 hw2 <file1> <file2>

HW1 was about parallelism on a shared-memory environment. HW2 is about parallism in a message-passing environment. There is no Java option for HW2.

Part 1

Your task is to implement a server and a client program. Two copies of server will run, and one copy of client will run. The servers are told a TCP port to listen on, and the client is given the addresses and ports of the two server:

./server 40001 &
./server 40002 &
time ./client localhost 40001 locahost 40002

The client should print the same result as the old hw1.c program with deconvert changed to call convert, but it farms out the work to the two servers, so it should produce a result twice as fast. The locahost above assumes that the clients are running on the same machines, but you can run clients on different machines, too.

(It might seem backward to have multiple servers and one client, but this arrangement makes it easy to start the servers first and then time the computation at the client.)

Start with the following files:

To help you get started with the message libraries, here are some extra files:

Compile them something like this:

gcc -o server -O2 -Wall server.c msg.c
gcc -o client -O2 -Wall client.c msg.c

Then run them like this, each in a different terminal window on the same machine:

./server 40001
./client localhost 40001

The server should print 0 through 4, as sent to it by the client. The client should print 100, as sent back to it by the server.

Part 2 (optional, extra credit)

Make your server work with an arbitrary number of clients, as determined by the number of command-line arguments supplied to it. Using multiple machines in the CADE lab, you should be able to get speedups greater than a factor of 2.


Last update: Monday, December 1st, 2008
mflatt@cs.utah.edu