Concurrency is hard. Context switches, cache inconsistencies and deadlocks can happen in unintuitive ways. When you write your code, you think about the happy path. When your OS runs it, it does everything it can to defy your assumptions.
We built a game that lets you play out how bad concurrency fails by playing the scheduler.
What it does
We have a campaign of 16 concurrency challenges. You can run it challenge by challenge, or play in any order you want. There is a story :)
Each challenge has several threads, each running their own C# code. Your objective is to make the code perform something forbidden - entering a critical section twice, entering a deadlock, etc. Our first challenge has a tutorial.
You execute individual threads command by command. You can expand non-atomic instructions into smaller operations (e.g., a nonatomic assignment has a separate load and store). You can also undo your actions.
Your progress is saved in HTML5 Local Storage.
It works well on mobile devices.
How we built it
Challenges we ran into
We had to brainstorm for a new project after our primary idea (which was a robot for Facebook Messenger) was obstructed by bad internet. We had to properly implement some tricky synchronization primitives.
Accomplishments that we're proud of
Despite having a 24-hour deadline, we finished the most important synchronization primitives. Overall, the app is rather polished (e.g. Back/Forward buttons work, it renders well on mobile phones, and we don't know about any bugs). We built many levels. We think we also did a pretty good job on the UI.
Finally, The Deadlock Empire is almost ready for publication and has the potential to help many students with understanding the intricacies of parallel programming.
What we learned
What's next for The Deadlock Empire
We'll add some levels and more primitives (both high-level and low-level), additional memory models and instruction reordering. We will publish it very soon.
The repository's on GitHub: https://github.com/deadlockempire/deadlockempire.github.io
Log in or sign up for Devpost to join the conversation.