Simulation Assignment 3 - Distributed Mutual Exclusion

Simulation, Spring 2005


Due Date

This assignment is due by 2:00 p.m. on Monday, 7 March at 2:00 p.m..

See the assignment turn-in page (last modified on 9 February 2004) for instructions on turning in your assignment.

Background

A system administrator manages a network of n hosts (n > 1). Each host has a wireless transmitter to a beeper carried by the system administrator. Whenever any host detects an important event, it sends a brief message to the administrator's beeper.

The administrator's beeper can handle only one message at a time; if a second host begins transmitting before the first host stops transmitting, the second host's message is lost. Because the hosts have only transmitters, they do not know the state of the channel, nor can they receive transmissions from the beeper (all hosts are, however, connected by a reliable wired network).

To make sure that no transmissions are lost, the hosts coordinate among themselves using a distributed mutual exclusion algorithm that insures that at most one host is transmitting at a time. The algorithm is

This algorithm, and the motivation behind it, are described in Time, Clocks, and the Ordering of Events in a Distributed System by Leslie Lamport, Communications of the ACM, July 1978 (vol. 21 no. 7), pages 558--565. This is possibly one of the ten - and certainly one of the twenty - most important papers in computing science.

The Problem

Determine the delay at a single host H between the time an important event occurs on H and the associated beeper message gets broadcast by H; delay is measured in ticks.

The following assumptions hold for this simulation:

  1. The wired network connecting the hosts does not lose or corrupt messages, nor does it re-order messages sent from a single host. However, you may not assume that all hosts receive messages in the same order.

  2. The time t in ticks between successive important events on any host is uniformly distributed between 0 and 1000, inclusive at both ends. Even though each host has the same distribution, the sequence of delays between important events will be different for each host.

  3. Each executable statement in the protocol takes one tick; executable statements are marked with a (*). If a node is not executing the protocol code, it is sitting in a loop executing one statement per clock tick.

    It takes five ticks for a message send-receive to occur, independent of the sending and receiving host and independent of broadcast or point-to-point transmission.

Input

Your simulation should accept two required command-line arguments:

$ dq-sim N T

The first argument N is the number of nodes in the system; the second argument T is the simulation duration in ticks. Assume that N > 1 and T > 49.

Your simulation may accept other inputs, but these must be optional inputs; it should be possible to run your simulation by supplying only the parameters N and T.

Output

Your simulation should write a single integer followed by a newline; the integer is the average delay between event and broadcast in ticks at one host (your choice of hosts).

If your simulation detects an illegal condition, such as invalid input parameters, it should print an error message to std-err and stop execution.

Grading

Each simulation will be graded independently of all other simulations for this assignment; there is no grade rationing.

Turn-In

You should turn-in your simulation code. You should also turn-in a brief three- or four-page report describing about your simulation. The report should describe

This report will be the basis for your presentation. The report should be in a generic format, such as plain text, PostScript, or Portable Document Format (pdf). Get in touch with me if you want to use something else.

You should include a makefile among the files you turn in, either for testing or to turn-in. Your makefile should understand two targets: go and clean. The go target should build your assignment. The clean target should delete all unnecessary files. Unnecessary files are any files generated by the makefile itself; such files include the .o files for C++, class files for Java, and any executables built by the makefile.

When you test or turn-in your project, the turn-in script runs (among other things) the following commands:

$ make clean

$ make go

You should make sure this works correctly.

See the assignment turn-in page (last modified on 9 February 2004) for instructions on turning in your assignment.


This page last modified on 19 March 2005.