How ardillachiki/2_intento_dekker works
Project Type and Purpose
• This is a single‐module Python simulation tool (CLI) illustrating Dekker’s mutual exclusion algorithm.
• It is neither a web app nor a microservice; it’s a self‐contained curses‐based, dual‐thread simulation.
High-Level Components
a. Main Controller (main.py)
b. UI Subsystem (curses windows)
c. Two Simulated Processes (threads or loop instances)
d. Shared State (flags: proceso1_puede_entrar, proceso2_puede_entrar; turn variable)
e. User Input Handler (waiting for Enter to cancel)
Component Interactions
• The Main Controller initializes the curses UI, shared flags, and launches the two process threads plus the input watcher.
• Each Simulated Process:
• Reads/writes shared flags and turn variable
• Requests CRS (Critical Section) entry per Dekker’s logic
• Writes its character (‘+’ or ‘*’) into its dedicated window via the UI subsystem
• The Shared State acts as the coordination medium enforcing mutual exclusion.
• The User Input Handler monitors keyboard; on Enter it sets cancelar, signaling both processes to exit their loops.
Architectural Patterns and Principles
• Concurrency with explicit shared memory synchronization (Dekker’s algorithm).
• Separation of concerns: UI rendering is decoupled from algorithm logic.
• Single‐responsibility threads: each process only runs the entry/critical/exit loop.
• Controlled shutdown via a shared cancellation flag.