comp.lang.ada
 help / color / mirror / Atom feed
From: russ lyttle <lyttlec@removegmail.com>
Subject: Re: Gnat Problem - Freezing too soon
Date: Sat, 2 Mar 2019 15:19:41 -0500
Date: 2019-03-02T15:19:41-05:00	[thread overview]
Message-ID: <q5eogs$eaq$1@gioia.aioe.org> (raw)
In-Reply-To: 161c749f-b9db-465f-8ffe-7900d3a4bff5@googlegroups.com

On 3/2/19 12:50 AM, Anh Vo wrote:
> On Friday, March 1, 2019 at 7:56:40 PM UTC-8, russ lyttle wrote:
>> On 3/1/19 8:08 PM, Anh Vo wrote:
>>> On Friday, March 1, 2019 at 1:50:12 PM UTC-8, russ lyttle wrote:
>>>> On 3/1/19 11:54 AM, Anh Vo wrote:
>>>>> On Friday, March 1, 2019 at 6:21:26 AM UTC-8, russ lyttle wrote:
>>>>>> On 2/28/19 7:49 PM, Anh Vo wrote:
>>>>>>> On Thursday, February 28, 2019 at 2:11:11 PM UTC-8, russ lyttle wrote:
>>>>>>>> On 2/28/19 4:22 PM, Simon Wright wrote:
>>>>>>>>> russ lyttle <lyttlec@removegmail.com> writes:
>>>>>>>>>
>>>>>>>>>> Example from the bookAnalysable Real-Time Systems :
>>>>>>>>>>
>>>>>>> ---------
>>>>>>>>
>>>>>>>> Would I be submitting a bug report against an already patched version of
>>>>>>>> gnat?
>>>>>>>
>>>>>>> Again, please post sporadics.ads in its entirety. So, we can duplicate your finding or not.
>>>>>>>      
>>>>>>>
>>>>>> Thanks for responding. We found it definitely a bug in gnat and are
>>>>>> submitting a bug report.
>>>>>
>>>>> It is fine to send in a report if you are confident that it is a bug in latest GNAT. Otherwise, we would like to see the content of sporadics.ads. So, we can either confirm or not your finding.
>>>>>     
>>>>>
>>>> Here they are. These are from Analysable Real-Time Systems Progrmmed in
>>>> Ada, Chap.20, Pg. 472-473. Line 29 gives different error from line 44.
>>>>
>>>> Full code for sporadics.ads:
>>>>
>>>> with System; use System;
>>>> with Ada.Real_Time; use Ada.Real_Time;
>>>> package Sporadics is
>>>>
>>>>       type Sporadic_Invoke_Interface is Synchronized Interface;
>>>>       procedure Start (S: in out Sporadic_Invoke_Interface)
>>>>          is abstract;
>>>>       type Any_Sporadic_Invoke_Interface is access all
>>>>         Sporadic_Invoke_Interface'Class;
>>>>
>>>>       type Sporadic_Thread_Interface is Synchronized Interface;
>>>>       procedure Wait_Start (S: in out Sporadic_Thread_Interface)
>>>>          is abstract;
>>>>       type Any_Sporadic_Thread_Interface is access all
>>>>         Sporadic_Thread_Interface'Class;
>>>>
>>>>       type Sporadic_State is abstract tagged
>>>>          record
>>>> 	 Pri : Priority;
>>>> 	 Ceiling_Priority : Priority;
>>>> 	 MIT_In_Mili : Time_Span;
>>>>          end record;
>>>>       procedure Initialize_Code (S: in out Sporadic_State)
>>>>          is abstract;
>>>>       procedure Sporadic_Code (S: in out Sporadic_State)
>>>>          is abstract;
>>>>       type Any_Sporadic_State is access all Sporadic_State'Class;
>>>>
>>>>       protected type Sporadic_Agent (S: Any_Sporadic_State)
>>>>         --with Priority => S.Ceiling_Prioriy
>>>>       is
>>>>          new Sporadic_Invoke_Interface and
>>>>              Sporadic_Thread_Interface
>>>>         with
>>>>         -- for the Start operation
>>>>         overriding procedure Start;
>>>>         overriding entry Wait_Start;
>>>>       private
>>>>          Start_Open : Boolean := False;
>>>>       end Sporadic_Agent;
>>>>
>>>>       task type Sporadic (S : Any_Sporadic_State;
>>>> 		       A : Any_Sporadic_Thread_Interface)
>>>>         with Priority => S.pri
>>>>           is
>>>>
>>>>       end Sporadic;
>>>> end Sporadics;
>>>> -----------------------------------------------------------------------
>>>> Full code for sporadics.adb:
>>>> package body Sporadics is
>>>>       protected body Sporadic_Agent is
>>>>          procedure Start is
>>>>          begin
>>>> 	 Start_Open := False;
>>>>          end Start;
>>>>
>>>>          entry Wait_Start
>>>>          when Start_Open is
>>>>          begin
>>>> 	 Start_Open := False;
>>>>          end Wait_Start;
>>>>       end Sporadic_Agent;
>>>>
>>>>          task body Sporadic is
>>>>          begin
>>>> 	 S.Initialize_Code;
>>>> 	 loop
>>>> 	    A.Wait_Start;
>>>> 	    S.Sporadic_Code;
>>>> 	 end loop;
>>>>          end Sporadic;
>>>>       end Sporadics;
>>>
>>> This problem also occurred with GNAT Community 2018 on Windows.
>>>
>>> While waiting for fixes in GNAT Community 2019, the work around is changing the definition of type Any_Sporadic_State as shown below.
>>>
>>>       type Any_Sporadic_State is not null access all Sporadic_State'Class;
>>>
>> Well, that worked. I may even come to understand why. Is this gnat only?
> 
> It is standard Ada. It means that the access variable must be not null.
> 
I understand that. I meant why it solved this particular problem. As far 
as I can tell, the authors never used the "not null" in any of their 
books. Would other compilers accept the code as written, or should the 
code be considered erroneous?
As Simon pointed out replacing "with Priority => S.pri" with "pragma 
Priority(S.pri)" also works. They never used that form either.

Why would the authors prefer one form over the others?


  reply	other threads:[~2019-03-02 20:19 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-28 18:34 Gnat Problem - Freezing too soon russ lyttle
2019-02-28 21:19 ` Anh Vo
2019-02-28 21:31   ` russ lyttle
2019-02-28 21:22 ` Simon Wright
2019-02-28 22:11   ` russ lyttle
2019-03-01  0:49     ` Anh Vo
2019-03-01 14:21       ` russ lyttle
2019-03-01 16:54         ` Anh Vo
2019-03-01 21:50           ` russ lyttle
2019-03-02  1:08             ` Anh Vo
2019-03-02  3:55               ` russ lyttle
2019-03-02  5:50                 ` Anh Vo
2019-03-02 20:19                   ` russ lyttle [this message]
2019-03-02 21:35                     ` Simon Wright
2019-03-03 20:42                       ` russ lyttle
2019-03-03 21:26                         ` Simon Wright
2019-03-04  0:33                           ` russ lyttle
2019-03-02 14:09             ` Simon Wright
2019-03-01  8:12     ` Simon Wright
2019-03-01 14:17       ` russ lyttle
2019-03-01 18:10     ` Simon Wright
2019-03-01 21:35       ` russ lyttle
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox