Skip to contentSkip to conversation

Maximum number of realtime tasks

Xenomai-help Frits de Klark 4 participants 7 messages Oct 31, 2006

lore
Share & tools
lore
#0 lore raw

Hello everyone,

I'm thinking about implementing a tcp/ip socket server where I assign each incoming connection 2 realtime tasks; 1 one for transmitting data and 1 for receiving data. I'm aware of the fact that the tasks will lose their realtime capacities, but I want to do some tests nonetheless.
I was wondering if there is a limit on the number of realtime tasks I can allocate and run at the same time. Is there any?
And may there be other problems to expect?

Thanks very much for your help,

Frits

#1 lore raw
Quoted 9 lines · Frits de Klark

Hello everyone,

I'm thinking about implementing a tcp/ip socket server where I assign each incoming connection 2 realtime tasks; 1 one for transmitting data and 1 for receiving data. I'm aware of the fact that the tasks will lose their realtime capacities, but I want to do some tests nonetheless.
I was wondering if there is a limit on the number of realtime tasks I can allocate and run at the same time. Is there any?

No limit on the number of concurrent tasks. Just make sure to have enough TCB space available from the Xenomai system heap (CONFIG_XENO_OPT_SYS_HEAP).

Quoted 2 lines

And may there be other problems to expect?

Depending on the runtime behaviour of your system, i.e. large number of ready-to-run tasks or outstanding timers at any given time, you may want to experiment with the scalability options from the nucleus configuration section.

Quoted 7 lines

Thanks very much for your help,

Frits
_______________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help

Signature · 1 line
Philippe.
#2 lore raw
In reply to Frits de Klark
Quoted 7 lines · Frits de Klark

Hello everyone,

I'm thinking about implementing a tcp/ip socket server where I assign each incoming connection 2 realtime tasks; 1 one for transmitting data and 1 for receiving data. I'm aware of the fact that the tasks will lose their realtime capacities, but I want to do some tests nonetheless. I was wondering if there is a limit on the number of realtime tasks I can allocate and run at the same time. Is there any?
And may there be other problems to expect?

Thanks very much for your help,

Pay attention to the stack size of the user-space tasks: the default of 8 Megabytes will exhaust your RAM rapidly. So, you should either :
- set the default stack size with ulimit;
- or set the the stack size of the created threads, but in this case the main thread will have an 8 Megabytes stack.

In order to set the stack size of a thread, use
pthread_attr_setstacksize if using the POSIX skin or the stksize parameter of rt_task_create if using the native skin.

Signature · 1 line
                                                 Gilles Chanteperdrix
#3 lore raw
Quoted 10 lines · Gilles Chanteperdrix

Pay attention to the stack size of the user-space tasks: the default of 8 Megabytes will exhaust your RAM rapidly. So, you should either :
- set the default stack size with ulimit;
- or set the the stack size of the created threads, but in this case the main thread will have an 8 Megabytes stack.

In order to set the stack size of a thread, use pthread_attr_setstacksize if using the POSIX skin or the stksize parameter of rt_task_create if using the native skin.

If I set the stacksize generally via ulimit -s and additionally via the pthread_attr_setstacksize() how is the precedence of one of these calls over the other ? Does pthread_attr_setstacksize

#4 lore raw
Quoted 8 lines · Daniel Schnell
Quoted 6 lines · Gilles Chanteperdrix

Pay attention to the stack size of the user-space tasks: the default of 8 Megabytes will exhaust your RAM rapidly. So, you should either :
- set the default stack size with ulimit;
- or set the the stack size of the created threads, but in this case the main thread will have an 8 Megabytes stack.

Quoted 8 lines
Quoted 3 lines

In order to set the stack size of a thread, use pthread_attr_setstacksize if using the POSIX skin or the stksize parameter of rt_task_create if using the native skin.

If I set the stacksize generally via ulimit -s and additionally via the pthread_attr_setstacksize() how is the precedence of one of these calls over the other ? Does pthread_attr_setstacksize

Setting the stack size with pthread_attr_setstacksize seems to allow a stack greater than the limit fixed by ulimit, but I do not think it is wise to rely on such a behaviour.

Signature · 1 line
                                                 Gilles Chanteperdrix
#5 lore raw
Quoted 3 lines · Gilles Chanteperdrix

Setting the stack size with pthread_attr_setstacksize seems to allow a stack greater than the limit fixed by ulimit, but I do not think it is wise to rely on such a behaviour.

If one wants to have always the same stack size for every thread than ulimit -s would be probably the way to go. But often in Realtime applications it is the preferred way of setting the stack size individually, so one doesn't waste too much memory. A mixture of both seems to be tempting: setting a general stack size and individually change it. So why not rely on this ? Which part in the system actually creates the stack for a Xenomai task and how is the interaction between Linux and Xenomai to derive the general system wide stack limit to a Xenomai task ?

Is there a way to find out, which thread has which stack size ?

Daniel

#6 lore raw
Quoted 8 lines · Daniel Schnell
Quoted 3 lines · Gilles Chanteperdrix

Setting the stack size with pthread_attr_setstacksize seems to allow a stack greater than the limit fixed by ulimit, but I do not think it is wise to rely on such a behaviour.

Quoted 9 lines

If one wants to have always the same stack size for every thread than ulimit -s would be probably the way to go. But often in Realtime applications it is the preferred way of setting the stack size individually, so one doesn't waste too much memory. A mixture of both seems to be tempting: setting a general stack size and individually change it. So why not rely on this ? Which part in the system actually creates the stack for a Xenomai task and how is the interaction between Linux and Xenomai to derive the general system wide stack limit to a Xenomai task ?

The way I understand ulimit (or the setrlimit syscall), it should be used to set a maximum limit, so the fact that pthread_attr_setstacksize allow to bypass this limit may be a bug that may be corrected one day. So, I repeat, I would not rely on this behaviour.

Quoted 2 lines

Is there a way to find out, which thread has which stack size ?

Each thread stack is set up as a mapping in /proc/pid/maps, so if you know one address on each stack, you may find out which thread has which stack. Ok, it is not easy, but I know no other way.

Signature · 1 line
                                                 Gilles Chanteperdrix