Segmentation fault in RT_TASK with too big arrays?
Hello,
I tried to create an int array with big size (up to 160k), but all sizes over 4096 throws segmentation faults!
That FAQ for POSIX skin tells me, that there is a variable thread stack size. Is there a equivalent native call for pthread_attr_setstacksize() ? Or do I have an other problem?
here is my code:
#include <stdio.h>
#include <signal.h>
#include <unistd.h>
#include <sys/mman.h>
#include <native/task.h>
#include <rtdk.h>
RT_TASK task;
void taskOne(void *arg)
{
rt_printf("starting task1\n");
int i;
int IWORK[160000];
for (i = 0; i < 20; i++) {
IWORK[i] = 0;
}
rt_printf("finished task1\n");
}void startup()
{
rt_timer_set_mode(0);
rt_task_create(&task, "task1", 0, 50, 0);
rt_task_start(&task, taskOne, 0);}
void init_xenomai() {
mlockall(MCL_CURRENT|MCL_FUTURE);
rt_print_auto_init(1);
}int main(int argc, char* argv[])
{
init_xenomai();
startup();
pause();
}
Quoted 7 lines · On 09/25/2012 02:59 PM, [email protected] wrote:
Hello,
I tried to create an int array with big size (up to 160k), but all sizes over 4096 throws segmentation faults! That FAQ for POSIX skin tells me, that there is a variable thread stack size. Is there a equivalent native call for
pthread_attr_setstacksize()? Or do I have an other problem?
The stack size is probably the issue. When using the native skin, the stack size is passed as a parameter to the rt_task_create function, see:
Signature · 1 line
Gilles.