Re: elaboration circularity detected problem, How to fix?

From: Scott Travak (s.travak_at_j-inet.com)
Date: 09/21/04


Date: Wed, 22 Sep 2004 06:15:58 +1000

Thanks for that Dennis and Ludovic! The both of you helped me out a lot on
this. From Dennis I realised that I could be splitting the 'Location'
package into two seperate packages "Location_Send' and 'Location_Receive'.
In that case circularity is removed. Ludovic pointed me towards a problem
being in Station.Chicago_Ptr not being initialised. The program works great
now.

Yep the tasks CHICAGO_RECEIVE and DESTINATION are still waiting for input. I
removed some code to make my posted code smaller. My original code controls
all shutdowns to all tasks.

Thanks so much again!

Cheers, Scott

"Ludovic Brenta" <ludovic.brenta@insalien.org> wrote in message
news:87y8j3foto.fsf@insalien.org...
>I had to modify Scott's code just a wee bit and I tried it on two
> compilers, one being GNAT 3.15p on Debian. None of the compilers gave
> any error message, and the program runs as expected. Here is my
> slightly amended version. The changes are:
>
> - place everything into one procedure, with nested packages
>
> - remove Station.Chicago_Ptr, which hides the top-level Chicago_Ptr
> but is different, since its pointers are left uninitialised. In
> fact, this may well be the source of the problem.
>
> Enjoy:
>
> with Ada.Text_Io;
> use Ada.Text_Io;
>
> procedure Circularity is
>
> type Location_Type is (Chicago, Paris, London);
>
> generic
> Centre : Location_Type;
> package Location is
> task type Send_Type is
> end Send_Type;
>
> task type Receive_Type is
> entry Ack_Channel;
> end Receive_Type;
>
> type Send_Ptr_Type is access Send_Type;
> type Receive_Ptr_Type is access Receive_Type;
>
> Send_Ptr : Send_Ptr_Type;
> Receive_Ptr : Receive_Ptr_Type;
> end Location;
>
>
> package Station is
> task Destination is
> entry Signal;
> end Destination;
> end Station;
>
>
> package body Location is
> task body Send_Type is
> Calls : Integer := 2;
> Done : Boolean := False;
> begin
> Put_Line (Location_Type'Image (Centre) & "_SEND alive");
> while Calls > 0 loop
> delay 0.1;
> Put_Line (Location_Type'Image (Centre) &
> " pings the Destination");
> Station.Destination.Signal;
> Calls := Calls - 1;
> end loop;
> Put_Line (Location_Type'Image (Centre) & "_SEND dead");
> end Send_Type;
>
>
> task body Receive_Type is
> Done : Boolean := False;
> begin
> Put_Line (Location_Type'Image (Centre) & "_RECEIVE alive");
> while not Done loop
> select
> accept Ack_Channel do
> Put_Line (Location_Type'Image (Centre) &
> " received an acknowledgement");
> end Ack_Channel;
> else
> delay 0.1;
> end select;
> end loop;
> Put_Line (Location_Type'Image (Centre) & "_RECEIVE dead");
> end Receive_Type;
> end Location;
>
>
> package Chicago_Ptr is new Location (Chicago);
>
>
> package body Station is
> task body Destination is
> Done : Boolean := False;
> begin
> Put_Line ("DESTINATION alive");
> while not Done loop
> select
> accept Signal do
> Put_Line ("DESTINATION: Received signal");
> Chicago_Ptr.Receive_Ptr.Ack_Channel;
> end Signal;
> else
> delay 0.1;
> end select;
> end loop;
> Put_Line ("DESTINATION dead");
> end Destination;
> end Station;
>
> begin
> Chicago_Ptr.Send_Ptr := new Chicago_Ptr.Send_Type;
> Chicago_Ptr.Receive_Ptr := new Chicago_Ptr.Receive_Type;
> end Circularity;
>
>
> The output is:
> ./circularity
> DESTINATION alive
> CHICAGO_SEND alive
> CHICAGO_RECEIVE alive
> CHICAGO pings the Destination
> DESTINATION: Received signal
> CHICAGO received an acknowledgement
> CHICAGO pings the Destination
> DESTINATION: Received signal
> CHICAGO received an acknowledgement
> CHICAGO_SEND dead
>
> The program does not exit; of course, the tasks CHICAGO_RECEIVE and
> DESTINATION are still waiting for input. Hence the program behaves as
> expected, at least for me.
>
> --
> Ludovic Brenta.



Relevant Pages

  • Re: elaboration circularity detected problem, How to fix?
    ... the Destination station sends an acknowledgement signal back to chicago's ... The code worked fine prior to changing the location package into a generic ... package body Location is ...
    (comp.lang.ada)
  • Re: Polymorphism: just another big word?
    ... > A station that should not allow TSquares just needs to load the ... > NoSquares package, and so-on. ... > package in much the same way that you can load and unload component ... > of inclusion lists which will need to be sent to each station saying ...
    (borland.public.delphi.non-technical)
  • RE: SSIS Newbie
    ... I will be running the package multiple times to get it right ... Table 1 file and send it to an OLE DB Destination (not SQL Destination) ... key1 steve smith 100 Park Street NoWhere Fl ...
    (microsoft.public.sqlserver.dts)
  • Re: too much aggro.
    ... You failed to include details about how far from the station your start ... and destination were, or availability of parking in London. ... That is about the same as the cost of the diesel but I can turn the key ...
    (uk.transport)
  • Re: Missing rows from Transform - Intermittent Issue??
    ... It is the rowcount in the ... destination you are using to determine how many rows were moved or are you ... Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP) ... > I execute the DTS package, ...
    (microsoft.public.sqlserver.dts)