Multithreading Demo

This project allows you to experiment with and demonstrate concurrency, the various problems it can cause, and solutions to those problems. You can demonstrate race conditions, deadlock, and synchronization primitives such as locks, condition variables and semaphores. Click "Open" in the top right to view an index of demo examples, or to create your own.

Basic Usage

A demo has two main sections, one globals section which is at the top, and one or more threads side by side at the bottom of the screen. You can have as many threads as you want, and can make your own programs. All of the threads can read and write to variables defined in the globals section, but threads can't access each other's data.

Once you have some code in the globals and threads sections, you can run the demo. You will see a compiled version of the code next to each thread, in MIPS-like assembly. You then act as the scheduler yourself, allowing you to control the exact order each thread gets executed in. You use the "step" button above each thread to move one instruction forward in its execution.

To be able to save a demo permanently you'll need to log in and make an account. Then, make sure to hit "Save" before you leave, so you don't have to remake the demo!

The Language

The language you can use is mostly a sub-set of C. You can set and modify variables, do arithmetic, and preform loops and conditionals. It can recognize 5 variable types: int, bool, mutex, cond_var, and sem.

You can use any of the 3 synchronization primitives, mutexes, condition variables, and semaphores. The following procedures and functions are available to work with them:

Examples

Playbacks

Once your have a demo set up, you may have specific paths of execution through the threads that cause whatever problem or situation you are trying to demonstrate. You can record those specific play throughs, and then play them back later. Use the record button, and then step through the threads as you would normally. When you are finished press the stop recording button and it will let you name and save the recorded playback. You can have multiple playbacks if you want. To replay the playback, select it from the playback dropdown and hit the play playback button (below the dropdown).