Inspiration

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 :) Campaign main menu

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. Tutorial challenge

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. A challenge in progress Expanded complex instructions Winning screen

Your progress is saved in HTML5 Local Storage. Saved progress

It works well on mobile devices.

How we built it

Deadlock Empire is a single-page JavaScript application. The UI is mostly Bootstrap and jQuery. We also used Bootbox for confirmation dialogs and Intro.js for a tutorial.

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

We learned Intro.js and exercised our JavaScript muscles.

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 code

The repository's on GitHub: https://github.com/deadlockempire/deadlockempire.github.io

Share this project:
×

Updates