This series of short projects demonstrates advanced knowledge and control of multithreading technology and the fundamentals of parallel programming.
These projects cover detached and joinable threads, mutexes, shared resources, and more.
Note: all projects must be run from the command line. All projects feature logic to put inactive threads to sleep until they are notified of a relevant state change, no threads are left in a spinlock.
DrinkingGame is a project that demonstrates multiple threads attempting to use 2 limited-amount shared resources without becoming deadlocked.
RaceCondition demonstrates how the placement of mutexes can change the result of a program suffering from a potential race condition. Run type 0 features no mutexes, resulting in the shared strings generated being mixed between threads, this is the race condition. Run type 1 has each thread generate an entire string while blocking other threads, then another thread is allowed to generate an entire string, and so on. Run type 2 has a thread generate all of its strings, then another thread is allowed to generate all of its strings, and so on. Run type 3 is similar to type 2 but the threads are organized by their thread id in the order in which they are allowed to generate their strings.
ReservationSystem is a project simulating many worker threads (car) requesting access to a limited-number shared resource (pump) through a manager (station). The resource manager uses a bitfield to track which resources are in use and distributes free resources (if available) to threads whey they request them. If there are no resources available the threads will be placed in a queue for the next available resource.
Note: this project runs with default parameters 10 2 30 (cars pumps time) if not specified.
This simple project starts a number of joinable and detached threads, generates junk work for them to do, then is notified when their work is complete. This project demonstrates knowledge in how to recieve work, start, and terminate joinable and detached thread types.
This project generates a large queue of simulated "work" for a few threads to process with one another, which takes the form of the game TicTacToe. A thread searches for any open games and joins one or starts a new game if it cannot find an open game. Once a game has 2 players it starts and one thread makes a move and then notifies the other thread to make a move. This continues until the game is won or tied when the threads taking part in the game will leave the game and search for more work to complete.