with os2;     use os2;
with os2.jba; use os2.jba;
with text_io; use text_io;
package Society is

  -- Dining Philosophers - Ada 95 edition (JBA - visual version)
  -- Society gives unique ID's to people, and registers their names
  -- Michael B. Feldman, The George Washington University, July, 1995.

-- Resurces

IDD_STATIC11        : constant long := 3011; --Static Text
IDD_STATIC12        : constant long := 3012; --Static Text
IDD_STATIC13        : constant long := 3013; --Static Text
IDD_STATIC20        : constant long := 3014; --Static Text
IDD_STATIC22        : constant long := 3015; --Static Text
IDD_STATIC23        : constant long := 3016; --Static Text
IDD_STATIC31        : constant long := 3017; --Static Text
IDD_STATIC32        : constant long := 3018; --Static Text
IDD_STATIC33        : constant long := 3019; --Static Text
IDD_STATIC41        : constant long := 3020; --Static Text
IDD_STATIC42        : constant long := 3021; --Static Text
IDD_STATIC43        : constant long := 3022; --Static Text
IDD_STATIC51        : constant long := 3023; --Static Text
IDD_STATIC52        : constant long := 3024; --Static Text
IDD_STATIC53        : constant long := 3025; --Static Text

--             Global variables.

wFrame              : aliased WINDOW ;
print               : text_io.file_type;
Table_Size : constant := 5;

subtype Unique_DNA_Codes is Positive range 1 .. Table_Size;
subtype Str35 is string(1..35) ;

type States is (Breathing, Thinking, Eating, Done_Eating,
                  Got_One_Stick, Got_Other_Stick, Dying);
type    Flags is array(Unique_DNA_Codes) of boolean ;
phil_pos : integer range 0..5  := 0 ; -- philosopher number

  Name_Register : array(Unique_DNA_Codes) of Str35 :=

   ("Edsger Dijkstra                    ",
    "Bjarne Stroustrup                  ",
    "Chris Anderson                     ",
    "Tucker Taft                        ",
    "Jean Ichbiah                       ");

WindowResurce : constant array(1..Table_size,1..3) of Long  -- resurce table
              := ((IDD_STATIC11,IDD_STATIC12,IDD_STATIC13),
                  (IDD_STATIC20,IDD_STATIC22,IDD_STATIC23),
                  (IDD_STATIC31,IDD_STATIC32,IDD_STATIC33),
                  (IDD_STATIC41,IDD_STATIC42,IDD_STATIC43),
                  (IDD_STATIC51,IDD_STATIC52,IDD_STATIC53));

WindowText    :  array(1..Table_size,1..3) of str35 ;-- string table

 In_Use        : Flags := (others => False);
 fl            : boolean   ;
 flag_start    : boolean := false ;

 protected get_number is -- get number
   entry Yes ( My_ID: out  Unique_DNA_Codes );
 end get_number;

 protected common_write is -- access to common veriable
   entry writer(s:str35;i,j:Unique_DNA_Codes);
   procedure free;
   procedure lock;
   private
    free_flag : boolean := true;
 end common_write;

 procedure Pick_Up (I:Unique_DNA_Codes );
 procedure Put_Down(I:Unique_DNA_Codes );
end Society;
