A distributed-systems lab project written in C using the Message Passing Interface (MPI). It demonstrates token-based mutual exclusion by coordinating access to a simulated shared printer across multiple processes.
The program creates a logical ring of exactly three MPI processes. A single token circulates from one process to the next, allowing only the process holding the token to enter the critical section and use the shared printer.
- Process 0 starts with the token.
- The token holder accesses and releases the simulated printer.
- The token is sent to the next process in the ring.
- After all processes have received it, the token returns to Process 0.
- Distributed processes with MPI
- Point-to-point communication using
MPI_SendandMPI_Recv - Token-ring topology
- Mutual exclusion and critical-section coordination
- Process ranks and inter-process synchronization
- A C compiler
- An MPI implementation such as Open MPI or Microsoft MPI
mpicc token_ring.c -o token_ringThe current implementation requires exactly three processes:
mpiexec -n 3 ./token_ringOn Windows, run the generated executable as follows:
mpiexec -n 3 token_ring.exetoken_ring.c— Implements the token-ring simulation and shared-printer coordination.