comp.lang.ada
 help / color / mirror / Atom feed
From: "Alexander Boucke" <alexb@lufmech.rwth-aachen.de>
Subject: Making a package safe for use by multiple tasks
Date: Fri, 7 Jun 2002 12:07:39 +0200
Date: 2002-06-07T10:07:42+00:00	[thread overview]
Message-ID: <adq0le$2np$1@nets3.rz.RWTH-Aachen.DE> (raw)

Hello!

I am just playing with the idea to use multiple tasks in a programm doing
linear algebra. The problem lies in my vector-algebra package, that uses
some global tmp-object to optimize memory use and reuse. To give you the
idea, some not necessarily correct code snippets what this is doing:

in the spec:

type values is array (<>) or real;
type vector is access values;

function "+" (left, right : vector) return vector;

in the body:

tmp_vec : vector;

function "+" (left, right : vector) return vector is
begin
   -- test here, if the tmp_vec is of correct size and allocated
   for i in tmp_vec'range loop
      tmp_vec(i) := left(i) + right(i);
   end loop;
   return tmp_vec;
end "+";

I hope this gives you the idea. In fact it is a little more complicated,
since I do reference counting on the vectors. The thing with the tmp_vec
enables me to reuse this vector several times, e.g. in d := a + b + c it is
not necessary to allocate it new every time, I could just overwrite tmp_vec
here.

This is of course not usable if I use more then one task! And converting the
whole thing in some kind of protected type is certainly not very useful,
since this would it would not allow parallel execution of vector operations
then.

Except of getting rid of these tmp_vec things, does anybody of you have an
idea, how this could be dealt with. The idea is, that every task needs to
have it's own temporary object. But I have no idea how this could be be
achieved in an automatic or semi-automatic way.

Thanks,

Alexander





             reply	other threads:[~2002-06-07 10:07 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-06-07 10:07 Alexander Boucke [this message]
2002-06-07 11:11 ` Making a package safe for use by multiple tasks Marc A. Criley
2002-06-07 11:47   ` Alexander Boucke
2002-06-07 13:31 ` Dr. Michael Paus
2002-06-07 13:44   ` Making a package safe for use by multiple tasks (Correction) Dr. Michael Paus
2002-06-07 15:00 ` Making a package safe for use by multiple tasks Ted Dennison
2002-06-07 16:37 ` Georg Bauhaus
2002-06-07 21:16 ` Jeffrey Carter
2002-06-08 13:14   ` Craig Carey
2002-06-08 13:39     ` Dr. Michael Paus
  -- strict thread matches above, loose matches on Subject: below --
2002-06-07 10:14 Grein, Christoph
2002-06-07 10:29 ` Alexander Boucke
replies disabled

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