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]

Re: Macro that ensures minimum stack size


>>>>> "Nick" == Nick Garnett <nickg@ecoscentric.com> writes:

    Nick> "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.
    >> 

    Nick> Personally I just define stack sizes as follows:

    Nick> #define STACK_SIZE (CYGNUM_HAL_STACK_SIZE_MINIMUM+<app usage>)

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

Actually, the synthetic target does require rather larger stacks than
other architectures. Because of the way interrupts are handled you can
end up with a couple of Linux signal contexts on an eCos thread stack,
and those need quite a lot of memory. To compensate for this
CYGNUM_HAL_STACK_SIZE_MINIMUM and CYGNUM_HAL_STACK_SIZE_TYPICAL are
set to suitably large values, so it is still correct to use those when
defining application stacks.

Bart

-- 
Bart Veer                       eCos Configuration 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


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