comp.lang.ada
 help / color / mirror / Atom feed
From: Niklas Holsti <niklas.holsti@tidorum.invalid>
Subject: Re: Simple 4 lines hang code using Ravenscar. Its this a Gnat bug?
Date: Fri, 22 Feb 2019 12:01:53 +0200
Date: 2019-02-22T12:01:53+02:00	[thread overview]
Message-ID: <gd9vkdFt12gU1@mid.individual.net> (raw)
In-Reply-To: <87222ca9-1b35-467c-9560-f44bd59e3e55@googlegroups.com>

On 19-02-22 10:56 , Daniel wrote:
>
> Hello,
> I found something strange using Ravenscar with Gnat. The code hangs without any explanation when i try to declare a task type...¡even if i dont use any variable of this type!!. If i quit the Ravenscar pragma it works well. This is the code:
>
> --MAIN PROCEDURE
> with tmr;
> with ada.Text_IO; use ada.Text_IO;
> procedure main is
> begin
>    put_line("Let's hang..");
> end main;
>
> --- TMR.ADS FILE
> pragma Profile (Ravenscar);
> package Tmr is
>    task type K_Timer is
>    end K_Timer;
> end Tmr;
>
> -- TMR.ADB FILE
> package body Tmr is
>    task body K_Timer  is
>    begin
>      null;
>    end K_Timer;
> end Tmr;
>
>
> Im using GNAT GPL 2017 for windows.
> Thank you and best regards.
>

In a Ravenscar program, no task should terminate, and this includes the 
environment task. However, your "main" subprogram, which is where the 
environment task ends up after elaboration, does terminate. Therefore no 
Ravenscar program is expected to terminate at all!

My guess is that without the task-type declaration, the tasking part of 
the Ravenscar run-time is omitted from the program, and the environment 
task can terminate and this terminates the program. With the task-type 
declaration, the Ravenscar tasking run-time is included, and termination 
of the environment task becomes a no-no. Or at least it no longer 
terminates the program, which therefore seems to "hang".

This is just a guess, of course.

You could try to put an eternal loop in the "main", say

    loop
       Put_Line ("Idling...");
       delay until Ada.Real_Time.Clock + Ada.Real_Time.Seconds (1);
    end loop;

HTH

-- 
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
       .      @       .


  reply	other threads:[~2019-02-22 10:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-22  8:56 Simple 4 lines hang code using Ravenscar. Its this a Gnat bug? Daniel
2019-02-22 10:01 ` Niklas Holsti [this message]
2019-02-22 12:48   ` Daniel
2019-02-22 10:17 ` AdaMagica
2019-02-22 12:55   ` Simon Wright
2019-02-22 12:55   ` Simon Wright
replies disabled

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