- 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
nslave threads. - Implemented coordinated behaviors between the master thread and
nslave 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 + 1processes in this synchronous distributed system: one master process andnslave 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
ronly if it is sure that all thenslave 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
idof lengthn:id[i]is the unique id of theithprocess
- The master thread reads these two inputs and then spawns
nthreads. - 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
jandj + 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.