How marcounie/dekker works
Project type and purpose
• This is a concurrency-synchronization utility (an open-source tool/library) that implements Dekker’s algorithm in Python.
• There is no frontend, backend or external service—just a single module providing mutual exclusion between two threads.
File structure
• Top-level:
– README.md ← contains only project title
– dekker.py ← contains the implementation of Dekker’s algorithm
• No subdirectories, no external dependencies beyond the Python standard library (threading).
README
• Only “# Dekker” is present—no additional architectural notes.
• Conclude that the README does not describe components; you must infer them from dekker.py.
Main components
a. Python Runtime / Interpreter
b. dekker.py Module (the “Dekker Algorithm” component)
c. Thread 1 and Thread 2 (consumer processes using the algorithm)
d. Shared Memory State:
– flag[0], flag[1]
– turn variable
Relationships & data flows
• Both Thread 1 and Thread 2 invoke “enter_critical_section()” and “exit_critical_section()” in the dekker.py module.
• dekker.py manipulates shared-memory flags and turn.
• After acquiring the lock, each thread proceeds into its critical section; upon exit, it clears its flag and gives up turn.
Architectural patterns & design principles
• Busy-waiting spinlock using Dekker’s two-process mutual exclusion algorithm.
• Single shared-memory concurrency—no message passing, no I/O, no networking.
• Separation of concerns: algorithm logic in dekker.py; client threads remain generic.
1. “Python Interpreter” (container)
2. “dekker.py” (module)
3. “Thread A” and “Thread B”
4. “Shared Memory” (flags & turn)
– From each Thread → dekker.py.enter_critical_section()
– dekker.py → Shared Memory (read/write flags & turn)
– Shared Memory → dekker.py (to check flags/turn)
– dekker.py.exit_critical_section() → Shared Memory
– Algorithm module in another (e.g., yellow)
– Shared Memory in a third (e.g., green)
Putting it all together
b. Inside it, place:
– Thread A → dekker.py.enter_critical_section()
– dekker.py ↔ Shared Memory
– dekker.py → Thread A (handoff into critical section)
– Similarly for Thread B