with text_io; use text_io;
with os2.jba;
with builtin; use builtin;
-- with dinnerdp;
package body Society is

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

   protected body get_number is
     entry Yes ( My_ID: out  Unique_DNA_Codes ) when true is
     begin
       phil_pos := phil_pos + 1 ;
       My_id := phil_pos ;
    end Yes ;

   end get_number;

 procedure Pick_Up(I:Unique_DNA_Codes) is
 begin
   loop
     if not In_Use (i) then
        In_Use (i) := true ;  exit;
     end if ;
     delay 0.05 ;
   end loop;
 end PIck_Up;

 procedure Put_Down(I:Unique_DNA_Codes) is
 begin
    In_Use(i) := False;
 end Put_Down;

 protected body common_write is -- access to common veriable
   entry writer(s:str35;i,j:Unique_DNA_Codes) when free_flag is
     begin WindowText(i,j) := s;
     new_line; put(WindowText(i,j));
     put_edit(" i=",i,2); put_edit("j=",j,2);
     if GuiPostMsg(wFrame'unchecked_access,16#20#,0,0) > 0 then Null; end if;
   end writer ;
   procedure free is begin free_flag:= true ; end free;
   procedure lock is begin free_flag:= false; end lock;
 end common_write;

end Society;

