This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Macro that ensures minimum stack size


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.

/David

Patch:

Index: kernel/current/include/kapi.h
===================================================================
RCS file: /usr/cvs/sw/ecos/packages/kernel/current/include/kapi.h,v
retrieving revision 1.1.1.3
diff -r1.1.1.3 kapi.h
163a164,181
>
> /*
>  * Support for different minimum stack sizes on different platforms.
>  * The macro below can be used to check that the specified stack
>  * is larger than the minimum stack size.
>  * The macro should be used when allocating a new stack, and when
>  * calling cyg_thread_create.
>  */
> #ifndef CYG_CHECK_FOR_MIN_STACK_SIZE_DEFINED
> #define CYG_CHECK_FOR_MIN_STACK_SIZE_DEFINED
> # include <cyg/hal/var_arch.h> // CYGNUM_HAL_STACK_SIZE_MINIMUM
> # ifdef CYGNUM_HAL_STACK_SIZE_MINIMUM
> # define CYG_CHECK_FOR_MIN_STACK_SIZE(_x_)   \
>          (_x_>CYGNUM_HAL_STACK_SIZE_MINIMUM ? _x_ :
CYGNUM_HAL_STACK_SIZE_MINIMUM)
> # else
> # define CYG_CHECK_FOR_MIN_STACK_SIZE(_x_)   (_x_)
> # endif
> #endif


David Marqvar
Development engineer, B.Sc.E.E.
Research & Development, BGAN uP-SW

Thrane & Thrane
Lundtoftegårdsvej 93D
DK-2800  Lyngby, Denmark
Direct:	+45 39 55 82 28
Reception:	+45 39 55 88 00
Fax:	+45 39 55 88 88
E-mail: 	dam@tt.dk
Internet:	http://www.tt.dk/


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]