comp.lang.ada
 help / color / mirror / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* Re: FIFO
  2017-09-16 17:52  6% ` FIFO Robert A Duff
  2017-09-16 18:11  0%   ` FIFO Frank Buss
@ 2017-09-17  9:46  0%   ` Simon Wright
  1 sibling, 0 replies; 12+ results
From: Simon Wright @ 2017-09-17  9:46 UTC (permalink / raw)


Robert A Duff <bobduff@TheWorld.com> writes:

> Frank Buss <fb@frank-buss.de> writes:
>
>> I need a FIFO with a fixed size,...
>
> Does Ada.Containers.Bounded_Synchronized_Queues meet your needs?
>
> - Bob

The implementation in GNAT GPL 2017 is not legal under Ravenscar
restrictions (the protected type Queue has two entries).

Also, what's the behaviour when the queue is already full? It blocks on
Enqueue, which would be a Bad Idea if called from an interrupt handler.


^ permalink raw reply	[relevance 0%]

* Re: FIFO
  2017-09-16 17:52  6% ` FIFO Robert A Duff
@ 2017-09-16 18:11  0%   ` Frank Buss
  2017-09-17  9:46  0%   ` FIFO Simon Wright
  1 sibling, 0 replies; 12+ results
From: Frank Buss @ 2017-09-16 18:11 UTC (permalink / raw)


On 09/16/2017 07:52 PM, Robert A Duff wrote:
> Frank Buss <fb@frank-buss.de> writes:
>
>> I need a FIFO with a fixed size,...
>
> Does Ada.Containers.Bounded_Synchronized_Queues meet your needs?

I guess it would work, but not available in ravenscar full for GNAT.

-- 
Frank Buss, http://www.frank-buss.de
electronics and more: http://www.youtube.com/user/frankbuss

^ permalink raw reply	[relevance 0%]

* Re: FIFO
  @ 2017-09-16 17:52  6% ` Robert A Duff
  2017-09-16 18:11  0%   ` FIFO Frank Buss
  2017-09-17  9:46  0%   ` FIFO Simon Wright
  0 siblings, 2 replies; 12+ results
From: Robert A Duff @ 2017-09-16 17:52 UTC (permalink / raw)


Frank Buss <fb@frank-buss.de> writes:

> I need a FIFO with a fixed size,...

Does Ada.Containers.Bounded_Synchronized_Queues meet your needs?

- Bob


^ permalink raw reply	[relevance 6%]

* Re: Asynchronous channels in Ada
  2016-02-19 21:45  6% ` Simon Wright
@ 2016-02-19 23:31  0%   ` Robert A Duff
  0 siblings, 0 replies; 12+ results
From: Robert A Duff @ 2016-02-19 23:31 UTC (permalink / raw)


Simon Wright <simon@pushface.org> writes:

> What about Ada.Containers.Bounded_Synchronized_Queues? (ARM A.18.29)
>
> (the ARM doesn't say what happens if the queue is full ... 

It does, but it's in A.18.27(10).

>...but I'm sure
> it does the right thing)

- Bob


^ permalink raw reply	[relevance 0%]

* Re: Asynchronous channels in Ada
  @ 2016-02-19 21:45  6% ` Simon Wright
  2016-02-19 23:31  0%   ` Robert A Duff
  0 siblings, 1 reply; 12+ results
From: Simon Wright @ 2016-02-19 21:45 UTC (permalink / raw)


What about Ada.Containers.Bounded_Synchronized_Queues? (ARM A.18.29)

(the ARM doesn't say what happens if the queue is full ... but I'm sure
it does the right thing)

(the AARM says "Since this type has a bounded capacity, Enqueue might
block if the queue is full", so I think we're OK!)

^ permalink raw reply	[relevance 6%]

* Re: "STORAGE_ERROR : s-intman.adb:139 explicit raise" from record containing a queue from Ada.Containers.Bounded_Synchronized_Queues in Gnat Ada 2014
  2015-02-27 19:26 14% "STORAGE_ERROR : s-intman.adb:139 explicit raise" from record containing a queue from Ada.Containers.Bounded_Synchronized_Queues in Gnat Ada 2014 jocpaine
  2015-02-28 10:08  7% ` Simon Wright
  2015-02-28 21:59 12% ` Stephen Leake
@ 2015-03-02  8:55  7% ` Egil H H
  2 siblings, 0 replies; 12+ results
From: Egil H H @ 2015-03-02  8:55 UTC (permalink / raw)


For what it's worth: On a 32-bit platform I get
- warning: "STORAGE_ERROR" will be raised at run time


^ permalink raw reply	[relevance 7%]

* Re: "STORAGE_ERROR : s-intman.adb:139 explicit raise" from record containing a queue from Ada.Containers.Bounded_Synchronized_Queues in Gnat Ada 2014
  2015-02-28 21:59 12% ` Stephen Leake
@ 2015-03-01 12:07  7%   ` AdaMagica
  0 siblings, 0 replies; 12+ results
From: AdaMagica @ 2015-03-01 12:07 UTC (permalink / raw)


Am Samstag, 28. Februar 2015 22:59:47 UTC+1 schrieb Stephen Leake:
> In type Queue, the discriminant Capacity has a default value, which
> means it is allowed to be changed,

No, I think Queue is limited, so the discriminant cannot be changed.

> in particular to Count_Type'last,
> which is large enough to cause Storage_Error.

^ permalink raw reply	[relevance 7%]

* Re: "STORAGE_ERROR : s-intman.adb:139 explicit raise" from record containing a queue from Ada.Containers.Bounded_Synchronized_Queues in Gnat Ada 2014
  2015-02-27 19:26 14% "STORAGE_ERROR : s-intman.adb:139 explicit raise" from record containing a queue from Ada.Containers.Bounded_Synchronized_Queues in Gnat Ada 2014 jocpaine
  2015-02-28 10:08  7% ` Simon Wright
@ 2015-02-28 21:59 12% ` Stephen Leake
  2015-03-01 12:07  7%   ` AdaMagica
  2015-03-02  8:55  7% ` Egil H H
  2 siblings, 1 reply; 12+ results
From: Stephen Leake @ 2015-02-28 21:59 UTC (permalink / raw)


jocpaine@googlemail.com writes:

> with Ada.Containers.Synchronized_Queue_Interfaces;
> with Ada.Containers.Bounded_Synchronized_Queues;
>
> procedure Q11 is
>
>  package Job_Queues_Interface is
>     new Ada.Containers.Synchronized_Queue_Interfaces
>       ( Element_Type => Integer );
>
>   package Job_Queues_Package is
>     new Ada.Containers.Bounded_Synchronized_Queues
>       ( Queue_Interfaces => Job_Queues_Interface
>       , Default_Capacity => 100 
>       );
>
>   subtype My_Queue_Type is Job_Queues_Package.Queue; 
>       
>   type Job_Queue is record
>                       Queue: My_Queue_Type;
>                     end record;  
>
>   q : Job_Queue;
>   -- This is the line causing the error. If I give q
>   -- My_Queue_Type instead, the error doesn't happen.

The declaration of Queue in Ada.Containers.Bounded_Synchronized_Queues
includes:

   protected type Queue
     (Capacity : Count_Type := Default_Capacity;
      Ceiling  : System.Any_Priority := Default_Ceiling)
   with
     Priority => Ceiling
   is new Queue_Interfaces.Queue with
   ...
   private
      List : Implementation.List_Type (Capacity);
   end Queue;

List_Type is:

      type List_Type (Capacity : Count_Type) is tagged limited record
         First, Last : Count_Type := 0;
         Length      : Count_Type := 0;
         Max_Length  : Count_Type := 0;
         Elements    : Element_Array (1 .. Capacity) := (others => <>);
      end record;

So if Capacity is large enough, you'll get Storage_Error.

In type Queue, the discriminant Capacity has a default value, which
means it is allowed to be changed, in particular to Count_Type'last,
which is large enough to cause Storage_Error. 

If you change Default_Capacity to 2**31-1, you get Storage_Error for
either case.

So apparently GNAT allocates the largest allowed space when you use type
Job_Queue, but when you use the type My_Queu_Type, it allocates the
space needed for the current discriminant.

-- 
-- Stephe

^ permalink raw reply	[relevance 12%]

* Re: "STORAGE_ERROR : s-intman.adb:139 explicit raise" from record containing a queue from Ada.Containers.Bounded_Synchronized_Queues in Gnat Ada 2014
  2015-02-27 19:26 14% "STORAGE_ERROR : s-intman.adb:139 explicit raise" from record containing a queue from Ada.Containers.Bounded_Synchronized_Queues in Gnat Ada 2014 jocpaine
@ 2015-02-28 10:08  7% ` Simon Wright
  2015-02-28 21:59 12% ` Stephen Leake
  2015-03-02  8:55  7% ` Egil H H
  2 siblings, 0 replies; 12+ results
From: Simon Wright @ 2015-02-28 10:08 UTC (permalink / raw)


GCC 4.9.1 gives a similar error (here, Mac OS X, it's Constraint_Error):
GCC 5.0.0 doesn't.

^ permalink raw reply	[relevance 7%]

* "STORAGE_ERROR : s-intman.adb:139 explicit raise" from record containing a queue from Ada.Containers.Bounded_Synchronized_Queues in Gnat Ada 2014
@ 2015-02-27 19:26 14% jocpaine
  2015-02-28 10:08  7% ` Simon Wright
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ results
From: jocpaine @ 2015-02-27 19:26 UTC (permalink / raw)


Hi. I've defined a queue type by instantiating Ada.Containers.Bounded_Synchronized_Queues . When I define a record with a field of that type, and then declare a variable of the record type, I get the storage error mentioned in the email subject line. That happens even if I never use the variable. However, if my variable is the queue type, I don't get the error. I'm surprised at that, because I'd expect a one-field record to have exactly the same storage layout as its field, so if one provokes the error, so should the other. That aside though, can anyone suggest a fix? 

Google shows me that similar errors have been reported before (not with the queue types): for example https://gcc.gnu.org/bugzilla/show_bug.cgi?id=42816 , "Bug 42816 - Crash in Ada.Containers.Vectors.Update_Element".

I'm using Gnat Ada 2014: specifically, gnatmake GPL 2014 (20140331) on Ubuntu 14.10 on version 3.16.0-30-generic of the Linux kernel. My program is below. I compiled it by doing
  gnatmake q11
from the file q11.adb . Running it by doing
  ./q11
gives the error.

Here's the program:

with Ada.Containers.Synchronized_Queue_Interfaces;
with Ada.Containers.Bounded_Synchronized_Queues;

procedure Q11 is

 package Job_Queues_Interface is
    new Ada.Containers.Synchronized_Queue_Interfaces
      ( Element_Type => Integer );

  package Job_Queues_Package is
    new Ada.Containers.Bounded_Synchronized_Queues
      ( Queue_Interfaces => Job_Queues_Interface
      , Default_Capacity => 100 
      );

  subtype My_Queue_Type is Job_Queues_Package.Queue; 
      
  type Job_Queue is record
                      Queue: My_Queue_Type;
                    end record;  

  q : Job_Queue;
  -- This is the line causing the error. If I give q
  -- My_Queue_Type instead, the error doesn't happen.
	
begin
  NULL;
end;

Thanks
Jocelyn Ireson-Paine
www.j-paine.org
www.jocelyns-cartoons.uk

^ permalink raw reply	[relevance 14%]

* Re: Simp,e example for 2 tasks
  @ 2014-09-21 20:33  8%   ` Jeffrey Carter
  0 siblings, 0 replies; 12+ results
From: Jeffrey Carter @ 2014-09-21 20:33 UTC (permalink / raw)


On 2014-09-21 7:31 AM, Stribor40 wrote:
> Would anyone be able to post simple example of ada program showing 2 tasks
> taking to each other please.  For example one task sends message to another
> saying "hi" and second taks replying "hi back".

As others have pointed out, Ada tasking is based on synchronous communication,
not the message queues found in other languages. This why Ada had to introduce
the partition concept to achieve distribution, while Erlang processes distribute
quite nicely by themselves, as the ping-pong example shows.

It follows that to have message passing in Ada one must create the mechanism
that stores a message from one task and allows another task to retrieve it. In
Ada 12 one can use the synchronized-queue containers for that.

with Ada.Containers.Synchronized_Queue_Interfaces;
with Ada.Containers.Bounded_Synchronized_Queues;
with Ada.Strings.Unbounded;

procedure Task_Example is
   package String_Queue_IF is new Ada.Containers.Synchronized_Queue_Interfaces
      (Element_Type => Ada.Strings.Unbounded.Unbounded_String);
   package String_Queues is new Ada.Containers.Bounded_Synchronized_Queues
      (Queue_Interfaces => String_Queue_IF, Default_Capacity => 1);

   A_To_B : String_Queues.Queue;
   B_To_A : String_Queues.Queue;

   task A;
   task B;

   task body A is
      Message : Ada.Strings.Unbounded.Unbounded_String;
   begin -- A
      A_To_B.Enqueue (New_Item => Ada.Strings.Unbounded.To_String ("Hi") );
      B_To_A.Dequeue (Element => Message);
   end A;

   task body B is
      Message : Ada.Strings.Unbounded.Unbounded_String;
   begin -- B
      A_To_B.Dequeue (Element => Message);
      B_To_A.Enqueue (New_Item => Ada.Strings.Unbounded.To_String ("Hi back") );
   end B;
begin -- Task_Example
   null;
end Task_Example;

-- 
Jeff Carter
"How'd you like to hide the egg and gurgitate
a few saucers of mocha java?"
Never Give a Sucker an Even Break
101


^ permalink raw reply	[relevance 8%]

* strange error in tiny ada 2012 program
@ 2012-07-06 21:55  8% Charly
  0 siblings, 0 replies; 12+ results
From: Charly @ 2012-07-06 21:55 UTC (permalink / raw)


Hi all

I installed the new GNAT GPL 2012 and started playing with the new Synchronized_Queue Containers.
Unfortunately I got serverall problems, which can be shown in the following tiny test program


 1  with Ada.Containers.Synchronized_Queue_Interfaces;
 2  with Ada.Containers.Bounded_Synchronized_Queues;
 3  with Ada.Text_IO;
 4  
 5  procedure Ctest is
 6  
 7  
 8     package Integer_Queue_Interfaces is
 9           new Ada.Containers.Synchronized_Queue_Interfaces (Integer);
10  
11     package Integer_Queues is
12       new Ada.Containers.Bounded_Synchronized_Queues (Integer_Queue_Interfaces, 10);
13  
14     subtype Integer_Queue_Type is Integer_Queues.Queue;
15  
16     -- type New_Integer_Queue_Type is new Integer_Queue_Type with null record;
17  
18     type Integer_Queue_Record is tagged limited record
19        Queue : Integer_Queue_Type;
20     end record;
21  
22     --Integer_Queue1 : Integer_Queue_Type;
23     Integer_Queue2 : Integer_Queue_Record;
24  
25  begin
26  
27     Ada.Text_IO.Put_Line ("Hello Ada");
28  
29  end Ctest;


First problem occured in line 16 where I want to extend the Integer_Queue_Type
but I got an error message:

ctest.adb:16:04: parent type of a record extension cannot be a synchronized tagged type (RM 3.9.1 (3/1))

So I removed the statement and defined a new tagged type with the Integer_Queue_Type as record element
in lines 18 - 20. This variant compiles without messages but now I get an exception STORAGE_ERROR.
addr2line locates the error in line 5 what isn't very usefull. By trial and error I found, that the
error comes from line 23, when I replace it with line 22 the program 'works'.

So my questions are:
Did I make any mistake in this tiny program or is it a bug in the new GNAT version?
How can a extend a proteced type (line 16).


Thanks



^ permalink raw reply	[relevance 8%]

Results 1-12 of 12 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2012-07-06 21:55  8% strange error in tiny ada 2012 program Charly
2014-09-21 13:31     Simp,e example for 2 tasks Stribor40
2014-09-21 17:00     ` Brad Moore
2014-09-21 20:33  8%   ` Jeffrey Carter
2015-02-27 19:26 14% "STORAGE_ERROR : s-intman.adb:139 explicit raise" from record containing a queue from Ada.Containers.Bounded_Synchronized_Queues in Gnat Ada 2014 jocpaine
2015-02-28 10:08  7% ` Simon Wright
2015-02-28 21:59 12% ` Stephen Leake
2015-03-01 12:07  7%   ` AdaMagica
2015-03-02  8:55  7% ` Egil H H
2016-02-19 21:02     Asynchronous channels in Ada Hadrien Grasland
2016-02-19 21:45  6% ` Simon Wright
2016-02-19 23:31  0%   ` Robert A Duff
2017-09-16 15:24     FIFO Frank Buss
2017-09-16 17:52  6% ` FIFO Robert A Duff
2017-09-16 18:11  0%   ` FIFO Frank Buss
2017-09-17  9:46  0%   ` FIFO Simon Wright

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