-- main program for Dining Philosophers simulation with Ada.Text_IO; use Ada.Text_IO; procedure Dining_Philosophers is subtype ID is Integer range 1..5; task Waiter is -- Waiter spec entry Pickup(I : in ID); entry Putdown(I : in ID); end task body Waiter is separate; task type Philosopher is -- Philosopher spec entry init(who : ID); end; DP : array(ID) of Philosopher; -- the philosophers rounds : Integer; -- number of rounds task body Philosopher is -- Philosopher body myid : ID; begin accept init(who); myid := who; end; for j in 1..rounds loop -- "think" Waiter.Pickup(myid); -- pick forks up -- "eat" Waiter.Putdown(myid); -- put forks down end loop; end Philosopher; begin -- read in rounds, then start the philosophers Get(rounds); for j in ID loop DP(j).init(j); end loop; end Dining_Philosophers;