๐ด 2 Philosophers - Both Fed Successfully
โ
Success!
Both philosophers successfully ate at least once during the simulation.
Look for each philosopher's "I'm full!" message in the diagram below!
Simulation Source Code
simulation =
DiningPhilosophers.create_simulation(
num_philosophers: 2,
think_time: 150,
eat_time: 75,
trace: true
)
|> ActorSimulation.run(duration: 1000)
sequenceDiagram
philosopher_1->>philosopher_1: {:start_hungry, :fork_0, :fork_1}
Note over philosopher_1,philosopher_1: t=150ms
philosopher_0->>philosopher_0: {:start_hungry, :fork_0, :fork_1}
Note over philosopher_0,philosopher_0: t=150ms
philosopher_1->>philosopher_1: {:mumble, "I'm hungry!"}
Note over philosopher_1,philosopher_1: t=150ms
philosopher_0->>philosopher_0: {:mumble, "I'm hungry!"}
Note over philosopher_0,philosopher_0: t=150ms
philosopher_1->>fork_0: {:request_fork, :philosopher_1}
Note over philosopher_1,fork_0: t=150ms
philosopher_0->>fork_0: {:request_fork, :philosopher_0}
Note over philosopher_0,fork_0: t=150ms
fork_0->>philosopher_1: {:fork_granted, :fork_0}
Note over fork_0,philosopher_1: t=150ms
fork_0->>philosopher_0: {:fork_denied, :fork_0}
Note over fork_0,philosopher_0: t=150ms
philosopher_1->>fork_1: {:request_fork, :philosopher_1}
Note over philosopher_1,fork_1: t=150ms
fork_1->>philosopher_1: {:fork_granted, :fork_1}
Note over fork_1,philosopher_1: t=150ms
philosopher_1->>philosopher_1: {:mumble, "I'm full!"}
Note over philosopher_1,philosopher_1: t=225ms
philosopher_1->>fork_0: {:release_fork, :philosopher_1}
Note over philosopher_1,fork_0: t=225ms
philosopher_1->>fork_1: {:release_fork, :philosopher_1}
Note over philosopher_1,fork_1: t=225ms
philosopher_0->>philosopher_0: {:start_hungry, :fork_0, :fork_1}
Note over philosopher_0,philosopher_0: t=300ms
philosopher_1->>philosopher_1: {:start_hungry, :fork_0, :fork_1}
Note over philosopher_1,philosopher_1: t=300ms
philosopher_0->>fork_0: {:request_fork, :philosopher_0}
Note over philosopher_0,fork_0: t=300ms
philosopher_1->>fork_0: {:request_fork, :philosopher_1}
Note over philosopher_1,fork_0: t=300ms
fork_0->>philosopher_0: {:fork_granted, :fork_0}
Note over fork_0,philosopher_0: t=300ms
fork_0->>philosopher_1: {:fork_denied, :fork_0}
Note over fork_0,philosopher_1: t=300ms
philosopher_0->>fork_1: {:request_fork, :philosopher_0}
Note over philosopher_0,fork_1: t=300ms
fork_1->>philosopher_0: {:fork_granted, :fork_1}
Note over fork_1,philosopher_0: t=300ms
philosopher_0->>philosopher_0: {:mumble, "I'm full!"}
Note over philosopher_0,philosopher_0: t=375ms
philosopher_0->>fork_0: {:release_fork, :philosopher_0}
Note over philosopher_0,fork_0: t=375ms
philosopher_0->>fork_1: {:release_fork, :philosopher_0}
Note over philosopher_0,fork_1: t=375ms
philosopher_1->>philosopher_1: {:start_hungry, :fork_0, :fork_1}
Note over philosopher_1,philosopher_1: t=450ms
philosopher_0->>philosopher_0: {:start_hungry, :fork_0, :fork_1}
Note over philosopher_0,philosopher_0: t=450ms
philosopher_1->>fork_0: {:request_fork, :philosopher_1}
Note over philosopher_1,fork_0: t=450ms
philosopher_0->>fork_0: {:request_fork, :philosopher_0}
Note over philosopher_0,fork_0: t=450ms
fork_0->>philosopher_1: {:fork_granted, :fork_0}
Note over fork_0,philosopher_1: t=450ms
fork_0->>philosopher_0: {:fork_denied, :fork_0}
Note over fork_0,philosopher_0: t=450ms
philosopher_1->>fork_1: {:request_fork, :philosopher_1}
Note over philosopher_1,fork_1: t=450ms
fork_1->>philosopher_1: {:fork_granted, :fork_1}
Note over fork_1,philosopher_1: t=450ms
philosopher_1->>philosopher_1: {:mumble, "I'm full!"}
Note over philosopher_1,philosopher_1: t=525ms
philosopher_1->>fork_0: {:release_fork, :philosopher_1}
Note over philosopher_1,fork_0: t=525ms
philosopher_1->>fork_1: {:release_fork, :philosopher_1}
Note over philosopher_1,fork_1: t=525ms
philosopher_0->>philosopher_0: {:start_hungry, :fork_0, :fork_1}
Note over philosopher_0,philosopher_0: t=600ms
philosopher_1->>philosopher_1: {:start_hungry, :fork_0, :fork_1}
Note over philosopher_1,philosopher_1: t=600ms
philosopher_0->>fork_0: {:request_fork, :philosopher_0}
Note over philosopher_0,fork_0: t=600ms
philosopher_1->>fork_0: {:request_fork, :philosopher_1}
Note over philosopher_1,fork_0: t=600ms
fork_0->>philosopher_0: {:fork_granted, :fork_0}
Note over fork_0,philosopher_0: t=600ms
fork_0->>philosopher_1: {:fork_denied, :fork_0}
Note over fork_0,philosopher_1: t=600ms
philosopher_0->>fork_1: {:request_fork, :philosopher_0}
Note over philosopher_0,fork_1: t=600ms
fork_1->>philosopher_0: {:fork_granted, :fork_1}
Note over fork_1,philosopher_0: t=600ms
philosopher_0->>philosopher_0: {:mumble, "I'm full!"}
Note over philosopher_0,philosopher_0: t=675ms
philosopher_0->>fork_0: {:release_fork, :philosopher_0}
Note over philosopher_0,fork_0: t=675ms
philosopher_0->>fork_1: {:release_fork, :philosopher_0}
Note over philosopher_0,fork_1: t=675ms
philosopher_1->>philosopher_1: {:start_hungry, :fork_0, :fork_1}
Note over philosopher_1,philosopher_1: t=750ms
philosopher_0->>philosopher_0: {:start_hungry, :fork_0, :fork_1}
Note over philosopher_0,philosopher_0: t=750ms
philosopher_1->>fork_0: {:request_fork, :philosopher_1}
Note over philosopher_1,fork_0: t=750ms
philosopher_0->>fork_0: {:request_fork, :philosopher_0}
Note over philosopher_0,fork_0: t=750ms
fork_0->>philosopher_1: {:fork_granted, :fork_0}
Note over fork_0,philosopher_1: t=750ms
fork_0->>philosopher_0: {:fork_denied, :fork_0}
Note over fork_0,philosopher_0: t=750ms
philosopher_1->>fork_1: {:request_fork, :philosopher_1}
Note over philosopher_1,fork_1: t=750ms
fork_1->>philosopher_1: {:fork_granted, :fork_1}
Note over fork_1,philosopher_1: t=750ms
philosopher_1->>philosopher_1: {:mumble, "I'm full!"}
Note over philosopher_1,philosopher_1: t=825ms
philosopher_1->>fork_0: {:release_fork, :philosopher_1}
Note over philosopher_1,fork_0: t=825ms
philosopher_1->>fork_1: {:release_fork, :philosopher_1}
Note over philosopher_1,fork_1: t=825ms
philosopher_0->>philosopher_0: {:start_hungry, :fork_0, :fork_1}
Note over philosopher_0,philosopher_0: t=900ms
philosopher_1->>philosopher_1: {:start_hungry, :fork_0, :fork_1}
Note over philosopher_1,philosopher_1: t=900ms
philosopher_0->>fork_0: {:request_fork, :philosopher_0}
Note over philosopher_0,fork_0: t=900ms
philosopher_1->>fork_0: {:request_fork, :philosopher_1}
Note over philosopher_1,fork_0: t=900ms
fork_0->>philosopher_0: {:fork_granted, :fork_0}
Note over fork_0,philosopher_0: t=900ms
fork_0->>philosopher_1: {:fork_denied, :fork_0}
Note over fork_0,philosopher_1: t=900ms
philosopher_0->>fork_1: {:request_fork, :philosopher_0}
Note over philosopher_0,fork_1: t=900ms
fork_1->>philosopher_0: {:fork_granted, :fork_1}
Note over fork_1,philosopher_0: t=900ms
philosopher_0->>philosopher_0: {:mumble, "I'm full!"}
Note over philosopher_0,philosopher_0: t=975ms
philosopher_0->>fork_0: {:release_fork, :philosopher_0}
Note over philosopher_0,fork_0: t=975ms
philosopher_0->>fork_1: {:release_fork, :philosopher_0}
Note over philosopher_0,fork_1: t=975ms