# roobeerr13/dekker-1er-intento architecture

> Architecture diagram of the GitHub repository roobeerr13/dekker-1er-intento, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/roobeerr13/dekker-1er-intento
- Repository: https://github.com/roobeerr13/dekker-1er-intento

## Overview

##### Project type and purpose
- This is a small Python project whose sole script, dekker1.py, implements Dekker’s mutual-exclusion algorithm for two “threads.”
- Its purpose is educational or demonstrative: show how two concurrent tasks coordinate via shared flags and a turn variable to safely enter a critical section.

##### File structure
- Top level:
- README.md – contains only the project title
- dekker1.py – the Python implementation
- No frontend, backend, database or external dependencies beyond Python’s standard threading library.

##### README for additional insights
- README only gives the project name ("dekker-1er-intento")

a. Main components
- Thread A (or Process A)
- Thread B (or Process B)
- Shared memory segment containing:
– flagA (Boolean)
– flagB (Boolean)
– turn (enum or int, indicating whose turn it is)
- Critical Section (the code region both threads contend for)
b. Relationships and interactions
- Both threads read/write the shared flags and turn variable.
- A common “entry protocol” before critical section, and “exit protocol” afterward.
c. Architectural patterns and design principles
- Concurrency control / mutual exclusion
- Busy-waiting (spinlock) pattern
- Single shared data store (no message passing)
d. Key technologies/frameworks
- Python threading module (Thread objects)
- Primitive shared variables (no high-level locks)

##### Diagramming recommendations
- Rectangles for Thread A and Thread B
- Critical section in red or bold to show exclusivity

##### Details to capture
- Sequence of operations in each thread’s entry protocol (set own flag, busy-wait on other flag and turn)
- The single shared “turn” variable as the tie-breaker
- The critical section’s boundary
- Exit protocol resetting the flag

## Diagram (Mermaid)

```mermaid
flowchart TB
    Project["dekker-1er-intento"]:::title
    subgraph "Thread A"
        A_entry["Entry Protocol\n(set flagA, busy-wait)"]:::threadA
        A_cs["Critical Section"]:::critical
        A_exit["Exit Protocol\n(reset flagA)"]:::threadA
    end
    subgraph "Shared Memory"
        SM_flagA["flagA"]:::shared
        SM_flagB["flagB"]:::shared
        SM_turn["turn"]:::shared
    end
    subgraph "Thread B"
        B_entry["Entry Protocol\n(set flagB, busy-wait)"]:::threadB
        B_cs["Critical Section"]:::critical
        B_exit["Exit Protocol\n(reset flagB)"]:::threadB
    end

    Project --> A_entry
    Project --> B_entry

    A_entry -->|writes| SM_flagA
    B_entry -->|writes| SM_flagB
    A_entry -->|writes| SM_turn
    B_entry -->|reads/writes| SM_turn
    SM_flagB -->|reads| A_entry
    SM_flagA -->|reads| B_entry

    A_entry --> A_cs --> A_exit
    B_entry --> B_cs --> B_exit

    A_exit -->|writes| SM_flagA
    B_exit -->|writes| SM_flagB

    %% Click events
    click Project "https://github.com/roobeerr13/dekker-1er-intento/blob/main/README.md"
    click A_entry "https://github.com/roobeerr13/dekker-1er-intento/blob/main/dekker1.py"
    click A_cs "https://github.com/roobeerr13/dekker-1er-intento/blob/main/dekker1.py"
    click A_exit "https://github.com/roobeerr13/dekker-1er-intento/blob/main/dekker1.py"
    click B_entry "https://github.com/roobeerr13/dekker-1er-intento/blob/main/dekker1.py"
    click B_cs "https://github.com/roobeerr13/dekker-1er-intento/blob/main/dekker1.py"
    click B_exit "https://github.com/roobeerr13/dekker-1er-intento/blob/main/dekker1.py"
    click SM_flagA "https://github.com/roobeerr13/dekker-1er-intento/blob/main/dekker1.py"
    click SM_flagB "https://github.com/roobeerr13/dekker-1er-intento/blob/main/dekker1.py"
    click SM_turn "https://github.com/roobeerr13/dekker-1er-intento/blob/main/dekker1.py"

    %% Styles
    classDef threadA fill:#AED6F1,stroke:#21618C,stroke-width:1px;
    classDef threadB fill:#ABEBC6,stroke:#1E8449,stroke-width:1px;
    classDef shared fill:#F2F3F4,stroke:#7B7D7D,stroke-width:1px;
    classDef critical fill:#F5B7B1,stroke:#C0392B,stroke-width:2px;
    classDef title fill:#FCF3CF,stroke:#B7950B,stroke-width:1px;
```
