Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Setting the stack size for an Ada main program?

595 views
Skip to first unread message

stuart clark

unread,
Mar 9, 2006, 10:23:05 AM3/9/06
to
Complete newbie to this group.

I am compiling some code using GNAT for VxWorks. The code has been
previously compiled using Apex for VxWorks.

I think under Apex there is a pragma to set the stack size for the main
program.

How do i do this under GNAT?

If i was writing pure VxWorks code, I think i can set the stack size in
the taskSpawn call?

However i am compiling exisitng high level Ada code and cross compiling
it. What techniques can i use at this level to set the stack size.

Examples, some linkers allow switches for stack size, eg windows where
gnatmake myprog -Wl,-stack_size, 0x40000, or for unix setenv
GNAT_STACK_LIMIT, it goes on....

Whats the best way to achieve this on VxWorks???

Stuart Clark

ashpat...@yahoo.co.uk

unread,
Mar 9, 2006, 10:45:04 AM3/9/06
to
The most straight forward method in the Ada code is to use the
following

task type MY_TASK_TYPE;
for MY_TASK_TYPE'STORAGE_SIZE use 20000;
MY_TASK : MY_TASK_TYPE;

It will also keep your code portable as oppose to setting it directly
from vxworks.
Be aware that the 20000 above will not be the resulting stack size
there is an overhead- so the resultant stack size is approximately
19200.

Regards

REH

unread,
Mar 9, 2006, 2:15:10 PM3/9/06
to

For VxWorks, the stack size of your Ada main is the stack size of the
task that it was called in. Thus, if you call your main via taskSpawn,
it is the stack size specified in that call. If you don't want to
worry about having the specify the stack size for main, leave your main
as a null statement, and create a task that will act as your real main.
This way you can give it a stack size in a standard way, and your
actual main will not terminate until that task does.

REH

stuart clark

unread,
Mar 9, 2006, 8:30:54 PM3/9/06
to
Thanks for the advice, i assume we use a taskSpawn to kick off our Ada
main. If so the we can simply put stack-size in the call to taskSpawn.

Do you know of any linker/binder options for VxWorks like the Windows

gnatmake my_prog -Wl,-stack_size,0x40000

i have seen a gnatbind option of -dnn[k|m] but that sets the default
task stack size, i assume this is for all tasks that dont have a pragma
storage_size().

Do you know if this also sets the main program, ie primary/environment
task???

please xcuse any "dumb" questions, i havent done a lot of VxWorks, and
not used gnat with VxWorks. I have done a little VxWorks but using
GreenHills.

You probalby know this but i found an option to adjust the stack size
in the debugger, ie
>set -wtx-task-stack-size .....

Once again thanks for the help.

REH

unread,
Mar 10, 2006, 6:53:22 AM3/10/06
to

"stuart clark" <stuart...@hotmail.com> wrote in message
news:1141954254....@v46g2000cwv.googlegroups.com...
It is not necessary to set the stack size for a Windows program. The OS
handles it automatically. If there is a way to manually handle it, I don't
know. I haven't done any Windows programming in 10 years. The mind is the
first thing to go...

You should ask in the comp.lang.ada group. There are a lot of smart people
there that know GNAT and they don't get upset about OS-specific questions.

REH


0 new messages