comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: Problems with dynamic allocation in tasks
Date: Wed, 25 Jul 2007 13:25:37 -0400
Date: 2007-07-25T13:25:37-04:00	[thread overview]
Message-ID: <wccvec8fl9q.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: 1185383088.872717.223020@l70g2000hse.googlegroups.com

ldb <ldb_nospam@hotmail.com> writes:

> I'm at a loss for how this possible using storage pools.

You're right -- it's not as simple as I implied.

> I've worked a good deal with storage pools but perhaps my vision of
> their functionality is too narrow. It was my belief that a storage
> pool can only be used globally for a particular type.

Correct.

The Allocate routine for your pool would have to grab a pointer to the
"real" pool out of thread-local storage, and allocate memory from that.
Whether thread-local storage is efficient enough depends on the
system.

I don't think there's any portable and efficient way to use thread-local
storage -- you'd have to program that.  Task_Attributes doesn't count --
it does locking, which is what you're trying to avoid.

>...These dynamic
> allocations are done with global types, ie, Access_Vector. Certainly a
> storage pool can be attached to Access_Vector and intercept, figure
> out which thread its in.. but then what? In a "simple" implementation,
> I'm still depending on System.Memory (which is malloc()) and it's
> still gonna hit these mutexes.
>
> I -could- make the storage-pool implement a full allocator so it's not
> dependant on malloc() for each allocation.

Well, yeah, if you implement your own storage pool, you have to
implement it.  ;-)

>...This is alot of work and
> there are alot of types.

Yes, it's a lot of work.  Not sure what you mean by "a lot of types".
Many types can share the same pool, if you program the pool to work
for multiple sizes and alignments.  You have to write
"for T'Storage_Pool use ..." on each type, though.

>...If I go this route, I'd prefer to do a global
> replace (which goes back to my original question of how to do it like
> gmem does it).

- Bob



  reply	other threads:[~2007-07-25 17:25 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-25 16:11 Problems with dynamic allocation in tasks ldb
2007-07-25 16:45 ` Robert A Duff
2007-07-25 17:04   ` ldb
2007-07-25 17:25     ` Robert A Duff [this message]
2007-07-25 18:35     ` Dmitry A. Kazakov
2007-07-26 20:56 ` 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