[ECOS] Macro that ensures minimum stack size

Nick Garnett nickg@ecoscentric.com
Thu May 1 14:05:00 GMT 2003


"David Marqvar (DAM)" <DAM@tt.dk> writes:

> We are developing software that we test on our hardware and with synth eCos.
> 
> Since the minimum stacksizes are different on the two platforms, and we
> don't want bigger stacks than needed, I have created a macro that can be
> used to ensure that the used stack size is above the minimum stack size for
> that hardware.
> 
> Example on use:
> 
> #define CONFIG_MANAGER_STACK_SIZE  CYG_CHECK_FOR_MIN_STACK_SIZE(4096)
> static char stack[CONFIG_MANAGER_STACK_SIZE]; /* space for a 4K stack */
> cyg_thread_create(4, configThread, (cyg_addrword_t) 0,
>                           "Thread 1", (void *) stack, 
>                           CONFIG_MANAGER_STACK_SIZE,
>                           &config_thread, &thread_s);
> 
> Have either of you solved this in another way, or -maybe- this macro could
> be usefull to others.
> 

Personally I just define stack sizes as follows:

#define STACK_SIZE (CYGNUM_HAL_STACK_SIZE_MINIMUM+<app usage>)

The amount of stack needed for an application is usually fairly
independent of the exact architecture. To me this seems a safer
approach than yours, since it guarantees that the app stack space is
always present.


-- 
Nick Garnett                    eCos Kernel Architect
http://www.ecoscentric.com/     The eCos and RedBoot experts


-- 
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss



More information about the Ecos-discuss mailing list