* [Xenomai-help] Stack size of created task
@ 2011-07-13 11:37 Jakub Nowacki
2011-07-13 11:43 ` Gilles Chanteperdrix
0 siblings, 1 reply; 4+ messages in thread
From: Jakub Nowacki @ 2011-07-13 11:37 UTC (permalink / raw)
To: xenomai
Hi,
I had a slight problem with freezing tasks in RTXI using Xenomai.
Namely, task was working normally for some time and then froze, but just
RTXI/task not the whole system. I've found that it was caused by the
stack size of a task set to 2000B during the creation. Changing it to 0,
i.e., automatic stack size fixed the freezing. My question is what is a
preferred value there? Before on the list I asked about a problem with
the stack size in the kernel being to small for switchtest to run
properly on i7 machine. There, one of the answers was that safe bet is
8kB for 64-bit machine. I'm not sure should I leave the stack size in
rt_task_create to 0 or to some high value or it should be machine
dependent? What is being put on this stack and how to determine it's
size depending on the complexity of the task (number of vars?)?
Cheers,
Jakub
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Xenomai-help] Stack size of created task
2011-07-13 11:37 [Xenomai-help] Stack size of created task Jakub Nowacki
@ 2011-07-13 11:43 ` Gilles Chanteperdrix
2011-07-13 13:13 ` Jakub Nowacki
0 siblings, 1 reply; 4+ messages in thread
From: Gilles Chanteperdrix @ 2011-07-13 11:43 UTC (permalink / raw)
To: Jakub Nowacki; +Cc: xenomai
On 07/13/2011 01:37 PM, Jakub Nowacki wrote:
> Hi,
>
> I had a slight problem with freezing tasks in RTXI using Xenomai.
> Namely, task was working normally for some time and then froze, but just
> RTXI/task not the whole system. I've found that it was caused by the
> stack size of a task set to 2000B during the creation. Changing it to 0,
> i.e., automatic stack size fixed the freezing. My question is what is a
> preferred value there? Before on the list I asked about a problem with
> the stack size in the kernel being to small for switchtest to run
> properly on i7 machine. There, one of the answers was that safe bet is
> 8kB for 64-bit machine. I'm not sure should I leave the stack size in
> rt_task_create to 0 or to some high value or it should be machine
> dependent? What is being put on this stack and how to determine it's
> size depending on the complexity of the task (number of vars?)?
The stack size of a task is highly dependent on what the task does, and
a little bit less on the architecture. There is no generic answer.
The problem with switchtest was not the task size, but the number of
kernel stacks which were available in the kernel threads stacks pool.
That is an entirely different issue.
--
Gilles.
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [Xenomai-help] Stack size of created task
2011-07-13 11:43 ` Gilles Chanteperdrix
@ 2011-07-13 13:13 ` Jakub Nowacki
2011-07-13 18:04 ` Gilles Chanteperdrix
0 siblings, 1 reply; 4+ messages in thread
From: Jakub Nowacki @ 2011-07-13 13:13 UTC (permalink / raw)
To: Gilles Chanteperdrix; +Cc: Xenomai help
On 07/13/2011 12:43 PM, Gilles Chanteperdrix wrote:
>
> The stack size of a task is highly dependent on what the task does, and
> a little bit less on the architecture. There is no generic answer.
>
Yes, that is understandable.
I've found in xenomai/inclues/arm-generic/stack.h that xeno_stack, which
is used in rt_task_create have a default value of __WORDSIZE*1024,
hence, 64kB on 64-bit system. So using 0 stack size in rt_create_stack
means that it'll be 64kB in my case, which seems to be a lot compared to
the previous version. Am I correct?
I'm still not sure should I assume that stack size 0, which is
(probably) __WORDSIZE*1024, is large enough for the vast majority of
practical cases or put it as a variable. Also, is there any way to
measure/asses the size of stack that is needed for a particular task or
just when it sudden crashes increase the stack size has to be increased?
I don't think that in RTXI very complicated RT tasks are used, so
default size should be more than enough, but I'm still not sure what
might indicate how large stack should be. As I understand it is related
to the amounts of memory being used by a task, which is put on the stack
during task switching, am I right?
> The problem with switchtest was not the task size, but the number of
> kernel stacks which were available in the kernel threads stacks pool.
> That is an entirely different issue.
>
I understand. I was referring to it because some 'safe' value of 8kB
appeared there.
Cheers,
Jakub
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Xenomai-help] Stack size of created task
2011-07-13 13:13 ` Jakub Nowacki
@ 2011-07-13 18:04 ` Gilles Chanteperdrix
0 siblings, 0 replies; 4+ messages in thread
From: Gilles Chanteperdrix @ 2011-07-13 18:04 UTC (permalink / raw)
To: Jakub Nowacki; +Cc: Xenomai help
On 07/13/2011 03:13 PM, Jakub Nowacki wrote:
> As I understand it is related
> to the amounts of memory being used by a task, which is put on the stack
> during task switching, am I right?
Not really. When a function starts, it reserves some room on stack,
mainly for local variables that can not be put in registers (because not
enough registers are available, or for other reasons, such as the fact
that the address of the variable needs to be passed to another function).
When this function calls another function, this other function reserves
room on top of the first stack reserved room, hence the name "stack".
The worst case is the highest level, it may be due to too many functions
reserving little space on stack, or to one function reserving too much
room on stack. For most functions, you can easily measure how much they
reserve on stack by looking at their disassembly. I guess there are perl
scripts around to edit a report of the stack usage of each function in a
binary.
--
Gilles.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-07-13 18:04 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-13 11:37 [Xenomai-help] Stack size of created task Jakub Nowacki
2011-07-13 11:43 ` Gilles Chanteperdrix
2011-07-13 13:13 ` Jakub Nowacki
2011-07-13 18:04 ` Gilles Chanteperdrix
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.