↓ Scroll down for Simulation notes.
Dining Philosophers Simulation
Legend:
[ T ] = Think[PUL] = Pick Up Left
[PUR] = Pick Up Right
[ E ] = Eat
[PDL] = Put Down Left
[PDR] = Put Down Right
[ B ] = Blocked
Simulation Notes
This Simulation Page lets you experiment with the algorithms.
Each run results in a unique timeline, based on the chosen algorithm and parameters.
The timelines often exceed the box width, so horizontal scrolling may be needed.
Parameters
- Number of philosophers: Simulations with 2–9 philosophers are possible.
- Execution Time: The simulation utilizes a Discrete Time-Stepping Virtual Time. One time "unit" represents a loop iteration that is a step in the simulation timeline. We control the actual time passage via a short waiting period in each iteration to give the philosophers time to complete actions. Philosophers use this reference time to log their respective actions after completion. This results in a quantization effect where each completed act is mapped to a discrete virtual simulation-time point. Note that there is an actual simulation running in the background that utilizes Java Threads. Increasing the simulation time will prolong the execution time of the backend, due to the longer simulation duration and the following processing of the results. The maximum execution time is 1000, this will result in a waiting period of up to 20 seconds before results are visible.
- Distribution settings: There are four distributions you can choose from.
- Deterministic: Only has one parameter and is a static delay. For the naive implementation, this will provoke deadlocks! (min: 30, max: 400)
- Interval: This distribution calculates a value between the given Lb = Lower Bound and Ub = Upper Bound. (Lb min: 30, Lb max: 400), (Ub min: 30, Ub max: 400)
- Normal: Has parameters mu = μ = the mean, and sigma = σ = the standard deviation. This will simulate philosophers with normally distributed delays, according to the given parameters. (μ min: 50, μ max: 250), (σ min: 1, σ max: 30)
- Exponential: Parameter lambda = λ = rate parameter. Frequent low values, but sometimes large outliers occur. Lower lambda means that higher values become more likely. (min: 3, max: 12)
- Simulation Type: Two types are available. The "Simulate Pickups"-mode lets you track the pick-ups and put-downs of the philosophers. Since simulating the pickups results in a slight overhead, there is also a "simple" mode, that is a little more performant and will return results quicker. The "simple" mode will only display thinking and eating.
- Timeout: Values between 0 and 200 are possible. A timeout of 0 is equivalent to an instant timeout.
Statistics
A simulation run will output detailed statistics, including the measures:
- Concurrency: Total combined (simulated) eating time, divided by length of the timeline. Maximum concurrency is bounded at [n/2](even n) or ⌊5/2⌋(odd n) for n-philosophers. Results close to this value indicate good concurrency.
- Eat-chance fairness: Standard deviation of all the philosophers eat chances (The times philosophers successfully picked up both chopsticks and ate)
- Eat-time fairness: Standard deviation of the philosophers accumulated simulation time spent eating. (The number of blocks per timeline that indicate eating)
For exponential and normal distributions, longer run times may help capture large outliers.