Add flowchart and clarify data representation

Added a flowchart to illustrate the Dining Philosophers Problem and clarified the representation of mutex variables and forks.
This commit is contained in:
Komeno 2025-11-11 15:25:08 +09:00 committed by GitHub
parent 26a3ebc206
commit 1f110b8f0a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -13,6 +13,49 @@ There are one or more philosophers sitting around a table, with a large bowl of
## Organizing data
```mermaid
flowchart TB
A("Dinner")
B(("Forks"))
C("Supervisor")
D{"Stop"}
E("Exit Status")
A --- B
A --- C
A --- D
A --- E
subgraph Rules
R0("Start Time")
R1("Philosopher Count")
R2("Philosopher Lifespan")
R3("Dining Duration")
R4("Rest Duration")
R5("Minimal Meals Count")
end
A --- Rules
subgraph Philosopher
D0("ID")
D1("Thread")
D2("Left Fork")
D3("Right Fork")
D4{"Times Eaten"}
D5{"Last Meal Time"}
end
A --- Philosopher
%% Clarifying relationships
Philosopher -->|accesses| B
```
description:
- A rhombus represent **mutex protected variables**
- A circle represent a **mutex array**
- In code, the left and right forks are represented as `forks[2]` where `forks[0]` represents the left fork and `forks[1]` the right fork
We will define our main data structure as:
```c