The Deadlock Empire
Slay dragons, master concurrency!
Welcome to The Deadlock Empire, commander!
The skills you need are your intelligence, cunning, perseverance and the will to test yourself against the intricacies of multi-threaded programming in the divine language of C#. Each challenge below is a computer program of two or more threads. You take the role of the Scheduler - and a cunning one! Your objective is to exploit flaws in the programs to make them crash or otherwise malfunction.
For example, you might cause a deadlock to occur or you might schedule context switches in such a way that two threads enter the same critical section at the same time. Any action that disrupts the program this way counts as a victory for you.
You are the Scheduler - you only have one tool at your disposal: the ability to switch contexts at any time, as the total master of time and interruptions. Let's hope it is enough... it has to be, because the Parallel Wizard's armies are upon us and only you can lead the Sequentialist armies into victory!
The skills you need are your intelligence, cunning, perseverance and the will to test yourself against the intricacies of multi-threaded programming in the divine language of C#. Each challenge below is a computer program of two or more threads. You take the role of the Scheduler - and a cunning one! Your objective is to exploit flaws in the programs to make them crash or otherwise malfunction.
For example, you might cause a deadlock to occur or you might schedule context switches in such a way that two threads enter the same critical section at the same time. Any action that disrupts the program this way counts as a victory for you.
You are the Scheduler - you only have one tool at your disposal: the ability to switch contexts at any time, as the total master of time and interruptions. Let's hope it is enough... it has to be, because the Parallel Wizard's armies are upon us and only you can lead the Sequentialist armies into victory!
Tutorial
Tutorial 1: Interface
Click here to begin the tutorial.
Tutorial 2: Non-Atomic Instructions
In the second tutorial, you will learn to expand statements.
Unsynchronized Code
Boolean Flags Are Enough For Everyone
Or so thinks the Deadlock Empire.
Simple Counter
Is the Deadlock Empire stupid?
Confused Counter
Could it be that some instructions are hidden from sight?
Locks
Insufficient Lock
Locks don't solve everything.
Deadlock
Stop the Empire army in its tracks!
A More Complex Thread
Three locks, two threads, one flag.
High-Level Synchronization Primitives
Manual Reset Event
Introduces the ManualResetEventSlim class, a no-fuss simple primitive.
Countdown Event
Introduces the CountdownEvent class, a more powerful barrier but also trickier.
Countdown Event Revisited
I fixed the bug. What are you going to do about it, huh?
The Barrier
The Deadlock Empire rolls out a new defensive weapon.
Semaphores
Semaphores
A semaphore is a simple synchronization primitive.
Producer-Consumer
A new victory condition awaits you!
Producer-Consumer (variant)
The victory conditions just keep coming!
Condition Variables
Condition Variables
Don't worry. It's not that hard.
The Final Stretch
Dragonfire
Withstand the onslaught of the Parallel Wizard's legions!
Triple Danger
You face not only a two-headed dragon, but a sorcerer as well!
Boss Fight
This is it. The final duel between the Master Scheduler and the Parallel Wizard.