[comp.sys.atari.st.tech] RTX programming questions

jg@hpldola.HP.COM (Joe Gilray) (07/26/90)

I have been using Micrortx to write a game based loosely on C-Robots.
But more about that when I'm ready to post it.

Right now I have two more Micrortx related questions:

1) I have a function that I am using as a process.  I want to be able
   to call this function many times and have each of the separate processes
   created in this way to be able to commit suicide when they are done.
   I have tried the following:

   A) p_delete((char *) NULL);
   B) p_delete(p_info((char *) NULL, &state));

   These should work and do sometimes but other times cause an error with
   the message (something like):

   "Unrecoverable loop error in exception processing"

   Other times the system hangs.

   BTW, making the process's stack larger seems to delay the problem.
   I.e. I can create more processes and have more of them successfully
   commit suicide before the problem occurs.

   The documentation indicates that a process should be able to commit
   suicide.

   The process function that is commiting suicide has four integer arguments
   passed to it, could this be causing the problem?  Do I need to clear
   them off the stack?

2) How big should I make a process's stack (the last argument to p_create)?

   I can think of two factors that affect stack size:

   A) number of arguments passed to the process
   B) The depth of calls made by the process.

Any ideas?

Thanks in advance
-Joe Gilray

david@bdt.UUCP (David Beckemeyer) (08/01/90)

In article <16960002@hpldola.HP.COM> jg@hpldola.HP.COM (Joe Gilray) writes:
>1) I have a function that I am using as a process.  I want to be able
>   to call this function many times and have each of the separate processes
>   created in this way to be able to commit suicide when they are done.
>   I have tried the following:
>
>   A) p_delete((char *) NULL);
>   B) p_delete(p_info((char *) NULL, &state));
>

The first case should work.  The second argument in the second case is
ignored.  If it isn't working all the time, then it's likly that some
RTX data structure is getting clobered. Perhaps you are overflowing
your stack, or have a bad pointer, or overran a Malloc'ed area.

SInce the function is started with p_create, it is also legal to
simply "fall off" the end of the function or do a "return"; this 
also kills the process.

>2) How big should I make a process's stack (the last argument to p_create)?
>
>   I can think of two factors that affect stack size:
>
>   A) number of arguments passed to the process
>   B) The depth of calls made by the process.
>

Another thing to watch for is using library routines supplied by the
compiler vendor; these often use up lot's of stack space.  You also have
to factor in all "automatic" variables which also require stack space.
Some RTX kernel calls also use stack space and so do some other system
calls (GEMDOS, BIOS, etc.).  If you can spare it, during debugging,
allocate 2K or 4K for "normal" stacks, and perhaps 16K for "big" stacks.

To verify stack overflows, try a really big stack like 64K and see if the
problems go away.

>-Joe Gilray

Good Luck!
-- 
David Beckemeyer (david@bdt.UUCP)	| "I'll forgive you Dad...  If you have
Beckemeyer Development Tools		| a breath mint."
P.O. Box 21575, Oakland, CA 94620	|    Bart - "The Simpsons"
UUCP: {uunet,ucbvax}!unisoft!bdt!david	|