Path: utzoo!utgpu!watmath!clyde!att!rutgers!bpa!cbmvax!bryce From: bryce@cbmvax.UUCP (Bryce Nesbitt) Newsgroups: comp.sys.amiga.tech Subject: Re: How do I find out how much stack space I have ?? Keywords: Amiga Exec Tasks Stack Message-ID: <5422@cbmvax.UUCP> Date: 4 Dec 88 06:25:32 GMT References: <42@ssibbs.UUCP> Reply-To: bryce@commodore.COM (Bryce Nesbitt) Organization: Commodore Technology, West Chester, PA Lines: 52 In article <42@ssibbs.UUCP> gnn@ssibbs.UUCP (George Neville-Neil) writes: > >OK. I am trying to find out a program's allocated Stack space. >I wrote a simple little test program that does this.... That won't do it. The stack is different from CLI and Workbench. If your compiler has a global that gives the stack size, then use it. Else: /* * stack_test.c 27-Oct-87. Bryce Nesbitt * */ #include "exec/types.h" #include "exec/tasks.h" #include "libraries/dosextens.h" #include "stdio.h" struct Process *FindTask(); void main() { register struct Process *Process; register FILE *Handle; struct CommandLineInterface *CLI; if (!(Handle=fopen("con:0/11/250/128/Stack Window","a"))) exit(20); /* "a" is used so the window won't flicker */ Process=FindTask(0L); if (CLI=(struct CommandLineInterface *)(Process->pr_CLI<<2)) { if (CLI->cli_Background) fprintf(Handle,"Background"); else fprintf(Handle,"Foreground"); fprintf(Handle," CLI #%ld\n",Process->pr_TaskNum); fprintf(Handle,"Actual stack is: %ld\n\n", CLI->cli_DefaultStack<<2); } else { fprintf(Handle,"This is not a CLI process\n"); fprintf(Handle,"Actual stack is %ld\n\n",Process->pr_StackSize); } Delay(100L); /* Be quick :-). BTW: *Never* Delay(0L);! */ fprintf(Handle,"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); /* Dramatic exit :-) */ fclose(Handle); }