public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* RE: [ECOS] Macro that ensures minimum stack size
@ 2003-05-01 17:31 David Marqvar (DAM)
  0 siblings, 0 replies; 5+ messages in thread
From: David Marqvar (DAM) @ 2003-05-01 17:31 UTC (permalink / raw)
  To: 'Nick Garnett'; +Cc: ecos-discuss

From: Nick Garnett [mailto:nickg@ecoscentric.com]

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

I see your point and agree. Will use it :-)

/David Marqvar


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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [ECOS] Macro that ensures minimum stack size
  2003-05-01 16:40   ` Bart Veer
@ 2003-05-01 17:14     ` Nick Garnett
  0 siblings, 0 replies; 5+ messages in thread
From: Nick Garnett @ 2003-05-01 17:14 UTC (permalink / raw)
  To: Bart Veer; +Cc: DAM, ecos-discuss, brm, FRJ

Bart Veer <bartv@ecoscentric.com> writes:

> >>>>> "Nick" == Nick Garnett <nickg@ecoscentric.com> writes:
>     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.
> 

I don't see how this differs from what I said. All the extra system
requirements are catered for in CYGNUM_HAL_STACK_SIZE_MINIMUM, leaving
the user to just work out and add what the application's stack usage
is, which should be fairly constant.

-- 
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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [ECOS] Macro that ensures minimum stack size
  2003-05-01 14:05 ` Nick Garnett
@ 2003-05-01 16:40   ` Bart Veer
  2003-05-01 17:14     ` Nick Garnett
  0 siblings, 1 reply; 5+ messages in thread
From: Bart Veer @ 2003-05-01 16:40 UTC (permalink / raw)
  To: nickg; +Cc: DAM, ecos-discuss, brm, FRJ

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [ECOS] Macro that ensures minimum stack size
  2003-05-01 11:30 David Marqvar (DAM)
@ 2003-05-01 14:05 ` Nick Garnett
  2003-05-01 16:40   ` Bart Veer
  0 siblings, 1 reply; 5+ messages in thread
From: Nick Garnett @ 2003-05-01 14:05 UTC (permalink / raw)
  To: David Marqvar (DAM)
  Cc: ecos-discuss, Brian Murphy (BRM), Frank Rolsted Jensen (FRJ)

"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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ECOS] Macro that ensures minimum stack size
@ 2003-05-01 11:30 David Marqvar (DAM)
  2003-05-01 14:05 ` Nick Garnett
  0 siblings, 1 reply; 5+ messages in thread
From: David Marqvar (DAM) @ 2003-05-01 11:30 UTC (permalink / raw)
  To: ecos-discuss; +Cc: Brian Murphy (BRM), Frank Rolsted Jensen (FRJ)

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2003-05-01 17:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-05-01 17:31 [ECOS] Macro that ensures minimum stack size David Marqvar (DAM)
  -- strict thread matches above, loose matches on Subject: below --
2003-05-01 11:30 David Marqvar (DAM)
2003-05-01 14:05 ` Nick Garnett
2003-05-01 16:40   ` Bart Veer
2003-05-01 17:14     ` Nick Garnett

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).