Skip to content

C++ solution and demonstration of the Santa Claus concurrency problem

License

Notifications You must be signed in to change notification settings

LaurieWired/SantaClausProblem

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Santa Claus Problem 🎅

This repository demonstrates the classic concurrency puzzle known as the Santa Claus Problem, originally described by John Trono. The problem requires synchronizing Santa, nine Reindeer returning from vacation, and a group of Elves needing Santa's help — ensuring that Santa only wakes up under the proper conditions. It highlights important concurrency concepts like resource sharing, scheduling, and synchronization constraints.

SantaDemo.mp4

What's in this repo? 🔎

  1. C++ Code

    • Provides two versions of the Santa Claus solution:
      • santa_bug.cpp - The original approach (contains a known scheduling assumption bug).
      • santa.cpp - A fixed solution properly handling the bug.
  2. Python Visualization

    • A Tkinter-based GUI that launches the C++ program in the background and animates Santa, Reindeer, and Elves.
    • Displays concurrency events, reindeer arrivals, and elves' help requests in an interactive way.

Quick Start 🏃

1. Compile the C++ code

g++ -std=c++20 santa.cpp -o santa

2. Run the Python GUI

python3 santa_ui.py

Why Does This Matter? 🤔

  • Concurrency: The Santa Claus Problem illustrates how multiple threads (or processes) can coordinate access to shared resources and synchronization primitives.
  • Scheduling Pitfalls: The classic solution can fail if threads are not scheduled as assumed. This repo showcases both the original approach and the improved fix.
  • Real-World Relevance: Understanding concurrency is essential for designing reliable, multi-threaded applications.

About

C++ solution and demonstration of the Santa Claus concurrency problem

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published