- Utilized multi-threading and concurrent primitives (threads, mutexes & condition variables in C++11 Thread Support Library) to develop a simple simulator which simulates a synchronous distributed system composed of one master thread and
n
slave threads. - Implemented coordinated behaviors between the master thread and
n
slave threads and message passing in undirected links between two slave threads by using monitors consisting of mutexes and condition variables - Implemented HS algorithm for leader election in synchronous ring networks under the framework of this simulator.
- Course: Distributed Computing (CS 6380)
- Professor: Subbarayan Venkatesan
- Semester: Fall 2016
- Programming Language: C++
- Build Tool: CMake
- You will develop a simple simulator that simulates a synchronous distributed system using multithreading.
- There are
n + 1
processes in this synchronous distributed system: one master process andn
slave processes. Each process will be simulated by one thread. - The master thread will "inform" all slave threads when one round starts.
- Each slave threads must wait for the master thread for a "go ahead" signal before it can begin round
r
. - The master thread can give the signal to start round
r
only if it is sure that all then
slave threads have completed their previous roundr - 1
.
Part Two: HS Algorithm
- Your simulation will simulate HS algorithm for leader election in synchronous ring networks.
- The code to implement HS algorithm executed by all slave threads must be the same.
- The input for this algorithm consists of two parts:
n
: the number of processes in this synchronous ring network- array
id
of lengthn
:id[i]
is the unique id of theith
process
- The master thread reads these two inputs and then spawns
n
threads. - All links in the ring network are bidirectional:
- There is one undirected link between processes
j - 1 (mod n)
andj
. - There is one undirected link between processes
j
andj + 1 (mod n)
.
- There is one undirected link between processes
- No process knows the value of
n
. - All processes must terminate after finding the leader's id.