comp.lang.ada
 help / color / mirror / Atom feed
* Task storage
@ 1998-02-24  0:00 Philippe Laval
  1998-02-24  0:00 ` Mats Weber
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Philippe Laval @ 1998-02-24  0:00 UTC (permalink / raw)



My Ada 95 application, compiled with Gnat 3.10 under Windows 95,
recursively allocates large tasks (about 1_000 instructions).
Storage_Error is raised after only a few ten tasks are created, despite
the 40 Mbytes available on my machine. I need about 12 Kbytes of stack
per task. The default storage pool is obviously too small. I would like
to set up a user defined pool object, according to the chapter 13.11 of
the ALRM, but the examples given make not very clear how Allocate could
be overridden to reserve 12 Kbytes each time "new" is executed. Where
can I find some examples which could be adapted to solve my problem?
-- 
Philippe Laval
Observatoire oceanologique - Villefranche-sur-Mer (France)
laval@obs-vlfr.fr




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Task storage
  1998-02-24  0:00 Task storage Philippe Laval
@ 1998-02-24  0:00 ` Mats Weber
  1998-02-24  0:00 ` Matthew Heaney
  1998-02-25  0:00 ` Jonas Nygren
  2 siblings, 0 replies; 4+ messages in thread
From: Mats Weber @ 1998-02-24  0:00 UTC (permalink / raw)



Philippe Laval wrote:

> My Ada 95 application, compiled with Gnat 3.10 under Windows 95,
> recursively allocates large tasks (about 1_000 instructions).
> Storage_Error is raised after only a few ten tasks are created, despite
> the 40 Mbytes available on my machine. I need about 12 Kbytes of stack
> per task. The default storage pool is obviously too small. I would like
> to set up a user defined pool object, according to the chapter 13.11 of
> the ALRM, but the examples given make not very clear how Allocate could
> be overridden to reserve 12 Kbytes each time "new" is executed. Where
> can I find some examples which could be adapted to solve my problem?

You probably don't need a non-default storage pool to solve this problem. Just
put a pragma Storage_Size(12_000); in your task spec and see what happens.




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Task storage
  1998-02-24  0:00 Task storage Philippe Laval
  1998-02-24  0:00 ` Mats Weber
@ 1998-02-24  0:00 ` Matthew Heaney
  1998-02-25  0:00 ` Jonas Nygren
  2 siblings, 0 replies; 4+ messages in thread
From: Matthew Heaney @ 1998-02-24  0:00 UTC (permalink / raw)



In article <34F30CB0.CD9@obs-vlfr.fr>, laval@obs-vlfr.fr wrote:

>My Ada 95 application, compiled with Gnat 3.10 under Windows 95,
>recursively allocates large tasks (about 1_000 instructions).
>Storage_Error is raised after only a few ten tasks are created, despite
>the 40 Mbytes available on my machine. I need about 12 Kbytes of stack
>per task. The default storage pool is obviously too small. I would like
>to set up a user defined pool object, according to the chapter 13.11 of
>the ALRM, but the examples given make not very clear how Allocate could
>be overridden to reserve 12 Kbytes each time "new" is executed. Where
>can I find some examples which could be adapted to solve my problem?

Why not use the Storage_Size pragma or Storage_Size attribute for the task
directly?

Using a storage pool would only control how the memory for the task
*object* gets allocated; it has nothing to say about the task itself.

I think the storage size attribute is what you want, ie

task type T is ...;
for T'Storage_Size use 12 * 1024;

You can also use pragma form

task type T (Size : Positive) is
   pragma Storage_Size (Size);
   entry E;
...
end T;

(I think that's it.  I haven't actually tried it yet.)




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Task storage
  1998-02-24  0:00 Task storage Philippe Laval
  1998-02-24  0:00 ` Mats Weber
  1998-02-24  0:00 ` Matthew Heaney
@ 1998-02-25  0:00 ` Jonas Nygren
  2 siblings, 0 replies; 4+ messages in thread
From: Jonas Nygren @ 1998-02-25  0:00 UTC (permalink / raw)
  To: laval


Philippe Laval wrote:
> 
> My Ada 95 application, compiled with Gnat 3.10 under Windows 95,
> recursively allocates large tasks (about 1_000 instructions).
> Storage_Error is raised after only a few ten tasks are created, despite
> the 40 Mbytes available on my machine. I need about 12 Kbytes of stack
> per task. The default storage pool is obviously too small. I would like
> to set up a user defined pool object, according to the chapter 13.11 of
> the ALRM, but the examples given make not very clear how Allocate could
> be overridden to reserve 12 Kbytes each time "new" is executed. Where
> can I find some examples which could be adapted to solve my problem?

This limitation is Win95 dependent. Windows and NT apparently set
aside a fixed size portion of the address space to use for the
per-thread data (stack, ...). This fixed size is determined by a
constant in the program which can be controlled via attributes
to the gnu linker, I don't remember exactly how this was done.

Gnat's default setting is a fairly large size for this area, most
users probably only have a few tasks and do not want to be bothered
with task size calculation. So a 'big-enough' size was chosen. If
you know what you're doing you could use the linker parameter
to change this size to fit your specific needs. I have tried this
and run with 1000+ thread scheduled Ada tasks in Gnat.

If you don't need to have thread scheduled tasks, ie you don't
have your tasks synchronised by the OS kernel (eg IO) then Gnat
provide support for such tasks also. I believe the number of such
tasks is only limited by available memory and you could use attributes
such as Storage_Size to manipulate the amount of memory allocated to
each task.

It was some time ago I looked into this and I hope my memory hasn't
failed me. You could also check some Gnat FAQ, if there is any.

/jonas




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1998-02-25  0:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-02-24  0:00 Task storage Philippe Laval
1998-02-24  0:00 ` Mats Weber
1998-02-24  0:00 ` Matthew Heaney
1998-02-25  0:00 ` Jonas Nygren

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