comp.lang.ada
 help / color / mirror / Atom feed
From: Nick Roberts <nick.roberts@acm.org>
Subject: Re: Converting access values
Date: Fri, 7 Jan 2005 16:55:13 +0000
Date: 2005-01-07T16:55:13+00:00	[thread overview]
Message-ID: <gemini.i9yho1003y2gn02as.nick.roberts@acm.org> (raw)
In-Reply-To: m31xczwgcl.fsf@0x535ba1f6.boanxx18.adsl-dhcp.tele.dk

Mark Lorenzen <mark.lorenzen@ofir.dk> wrote:

> ...
> My problem is not passing a slice as an actual parameter to a subprogram.
> I have a task which receives Buf, slices it up and then passes the slices
> to other tasks using queues implemented as protected types. When passing
> the slice to a queue, it will probably not be done by copy, but the queue
> puts the slice into a data structure (list, array etc.) and there we
> definately have a real assignment and copy.

Mark, you are a silly sausage! All you do is pass the /bounds/ to the tasks.
When a task finally comes to actually process a slice, it uses the bounds
passed to it to obtain the actual slice of the buffer. Since there is only
one buffer, it can be a global, and parts of it do not need to be passed as
a parameter anywhere. Would this not work for you?

I can do a lot of guessing and suggest a skeleton:

   Buffer: Stream_Element_Array(0..4095);

   type Bounds is record First, Last: Stream_Element_Offset; end record;

   procedure Flabbergnosticate (Slice: in Bounds) is
      ...
   begin
      for i in Slice.First .. Slice'Last loop
         Flabber( Buffer(i), Temp );
         Gnosticate( Temp, Buffer(Slice.First..Slice'Last) );
      end loop;
   end;

   task Allocator is
      ...
   end;

   task Processor is
      ...
      entry Allocate (Slice: in Bounds);
      entry Retire_Slice;
      ...
   end;

   type Processor_ID is mod 200;

   Procs: array (Processor_ID) of Processor;

   task body Processor is
      ...
      Slice: Bounds;
      Busy:  Boolean := False;
   begin
      loop
         select
            ...
         or when not Busy =>
            accept Allocate (Slice: in Bounds) do
               Processor.Slice := Slice;
               Processor.Busy  := True;
            end;
            Flabbergnosticate( Slice );
         or when Busy =>
            accept Retire_Slice do
               Busy := False;
            end;
         end select;
      end loop
      ...
   end;

The Allocator task, here, is responsible for ensuring that no slice of the
buffer is refilled with data before it has been processed and retired. This
could be quite complicated (I've not attempted to show a body for this
task). I think perhaps the use of protected types is not appropriate in this
case, therefore (but I have done a lot of guessing).

Does this actually solve your problem, or am I missing something?

-- 
Nick Roberts



  reply	other threads:[~2005-01-07 16:55 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-01-05 22:31 Converting access values Mark Lorenzen
2005-01-05 23:32 ` Stephen Leake
2005-01-05 23:51   ` Mark Lorenzen
2005-01-06  0:18 ` Jeffrey Carter
2005-01-06  0:28   ` Mark Lorenzen
2005-01-07 16:55     ` Nick Roberts [this message]
2005-01-07 19:49       ` Mark Lorenzen
2005-01-07 20:23         ` Nick Roberts
2005-01-07 21:23           ` Robert A Duff
2005-01-11 17:02             ` Upkeep
2005-01-11 21:37               ` Robert A Duff
2005-01-12  4:56                 ` Alexander E. Kopilovich
2005-01-12 10:48                 ` Dmitry A. Kazakov
2005-01-07 21:17         ` Randy Brukardt
2005-01-07 22:15           ` Robert A Duff
2005-01-06 10:52 ` Dmitry A. Kazakov
2005-01-06 11:02 ` Duncan Sands
2005-01-06 12:17   ` Martin Dowie
2005-01-06 19:30   ` Mark Lorenzen
2005-01-06 20:40     ` Randy Brukardt
replies disabled

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