LemIPC

The idea

The goal of this project was to create a boardgame on which we could make fight multiple teams. The boardgame had to be displayed from the first time we ran the game to the last team standing on the map, and along this time, a player represented by a new process could be added to a team by running again the game with the right arguments. A player dies whenever there is two ennemies of the same team surrounding him.

IPC : Inter-Process Communication

IPCs are used as a mechanism to communicate between several processes (in this context, the players of each team).

There are plenty of them but in this context, we needed those three :

Shared Memory

A shared memory is a system that allows several processes to read and write on a single segment of memory.

Semaphore

A semaphore is used to limit the access to a part of a program for processes. It is really important to know how to use it as it is a mechanism that synchronizes each process with each other.

Message Queue

Message queue allows us to really communicate between processes, as it allows to send and read alot of data.

We created a small program to test all those IPCs and we began with the shared memory which actually contained the boardgame. Then we created the algorithm which added new players and teams on the boardgame, using a simple semaphore, almost like a mutex for threads, for each new process to write on the boardgame.

Finally we tried to use message queue by appointing a captain in each team which could then lead all the team to an enemy player, generally the closest one to the captain. As it turned out, we couldn’t get anything working properly, we took a step back and we decided that each player/process searches for an enemy and finds its way to it.

Conclusion

We really liked this project as it was the following of ‘The Dining Philosophers’ project that we did earlier and took our understanding of processes and communication between them also as their synchronization to a whole new level which we are glad to have now. We now have all the tools that we need to begin ‘The Plazza’ …