* [Xenomai-help] error creating a task with rt_task_spawn
@ 2008-06-24 12:36 Karl Reichert
2008-06-24 12:50 ` Sebastian Smolorz
0 siblings, 1 reply; 4+ messages in thread
From: Karl Reichert @ 2008-06-24 12:36 UTC (permalink / raw)
To: xenomai
Hello,
I'm trying to create and start a new thread via rt_task_spawn() but I always get error -3. ("Unknown error: -3")
Any idea?
Thanks in advance
Karl
#include "main.h"
#include <stdio.h>
#include <signal.h>
#include <native/task.h>
#include <native/timer.h>
#include <native/mutex.h>
#include <sys/mman.h>
int i,j,x;
RT_TASK *rx_tsk;
int ret1;
int ret2;
void rx_task(void *cookie);
void cleanup(int dummy);
int main (int argc, char* argv[])
{
i = 0;
if ( -1 == mlockall (MCL_CURRENT | MCL_FUTURE) ) {
perror("mlockall: ");
return -1;
}
ret1 = rt_task_spawn(rx_tsk, "rx_task", 0, 1, T_FPU|T_CPU(1), &rx_task, NULL);
if( ret1 != 0 )
{
switch(ret1)
{
case -ENOMEM: printf("no memory!\n");
break;
case -EEXIST: printf("already registered!\n");
break;
case -EPERM: printf("asychron context!\n");
break;
default: printf("Unknown error: %i\n", ret1);
break;
}
return -2;
}
for(;i<10000;)
{
x=i/23%2;
i++;
}
ret2 = rt_task_delete(rx_tsk);
if( 0 != ret2 )
{
printf("delete error: %i\n", ret2);
return -3;
}
return 0;
}
void rx_task(void *cookie)
{
j=0;
j++;
while(1);
}
--
von Karl Reichert
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [Xenomai-help] error creating a task with rt_task_spawn
2008-06-24 12:36 [Xenomai-help] error creating a task with rt_task_spawn Karl Reichert
@ 2008-06-24 12:50 ` Sebastian Smolorz
2008-06-24 13:00 ` Karl Reichert
0 siblings, 1 reply; 4+ messages in thread
From: Sebastian Smolorz @ 2008-06-24 12:50 UTC (permalink / raw)
To: Karl Reichert; +Cc: xenomai
Karl Reichert wrote:
> Hello,
>
> I'm trying to create and start a new thread via rt_task_spawn() but I always get error -3. ("Unknown error: -3")
>
> Any idea?
> #include "main.h"
>
> #include <stdio.h>
> #include <signal.h>
> #include <native/task.h>
> #include <native/timer.h>
> #include <native/mutex.h>
> #include <sys/mman.h>
>
> int i,j,x;
> RT_TASK *rx_tsk;
This is a (uninitialized) pointer ...
Maybe you wanted to type
RT_TASK rx_tsk;
?
>
> int ret1;
> int ret2;
>
> void rx_task(void *cookie);
> void cleanup(int dummy);
>
> int main (int argc, char* argv[])
> {
> i = 0;
>
> if ( -1 == mlockall (MCL_CURRENT | MCL_FUTURE) ) {
> perror("mlockall: ");
> return -1;
> }
>
> ret1 = rt_task_spawn(rx_tsk, "rx_task", 0, 1, T_FPU|T_CPU(1), &rx_task, NULL);
Here you call rt_task_spawn with that pointer rx_tsk. You must provide a
valid pointer, e.g. &rx_tsk and modify the definition of rx_tsk as above.
--
Sebastian
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [Xenomai-help] error creating a task with rt_task_spawn
2008-06-24 12:50 ` Sebastian Smolorz
@ 2008-06-24 13:00 ` Karl Reichert
2008-06-24 13:16 ` Sebastian Smolorz
0 siblings, 1 reply; 4+ messages in thread
From: Karl Reichert @ 2008-06-24 13:00 UTC (permalink / raw)
To: Sebastian Smolorz; +Cc: xenomai
> Karl Reichert wrote:
> > Hello,
> >
> > I'm trying to create and start a new thread via rt_task_spawn() but I
> always get error -3. ("Unknown error: -3")
> >
> > Any idea?
>
> > #include "main.h"
> >
> > #include <stdio.h>
> > #include <signal.h>
> > #include <native/task.h>
> > #include <native/timer.h>
> > #include <native/mutex.h>
> > #include <sys/mman.h>
> >
> > int i,j,x;
> > RT_TASK *rx_tsk;
>
> This is a (uninitialized) pointer ...
> Maybe you wanted to type
> RT_TASK rx_tsk;
> ?
>
> >
> > int ret1;
> > int ret2;
> >
> > void rx_task(void *cookie);
> > void cleanup(int dummy);
> >
> > int main (int argc, char* argv[])
> > {
> > i = 0;
> >
> > if ( -1 == mlockall (MCL_CURRENT | MCL_FUTURE) ) {
> > perror("mlockall: ");
> > return -1;
> > }
> >
> > ret1 = rt_task_spawn(rx_tsk, "rx_task", 0, 1, T_FPU|T_CPU(1), &rx_task,
> NULL);
>
> Here you call rt_task_spawn with that pointer rx_tsk. You must provide a
> valid pointer, e.g. &rx_tsk and modify the definition of rx_tsk as above.
Yes, you are right. My fault ...
But after modifying, when I run this program, the computer locks. I can move the mouse and even mouve the windows (Xfree), but I can neither close the window, click any buttons nor enter anything in the terminal-window.
Any ideas?
Thanks
Karl
--
von Karl Reichert
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [Xenomai-help] error creating a task with rt_task_spawn
2008-06-24 13:00 ` Karl Reichert
@ 2008-06-24 13:16 ` Sebastian Smolorz
0 siblings, 0 replies; 4+ messages in thread
From: Sebastian Smolorz @ 2008-06-24 13:16 UTC (permalink / raw)
To: Karl Reichert; +Cc: xenomai
Karl Reichert wrote:
> Yes, you are right. My fault ...
>
> But after modifying, when I run this program, the computer locks.
> I can move the mouse and even mouve the windows (Xfree), but I can
> neither close the window, click any buttons nor enter anything in
> the terminal-window.
>
> Any ideas?
Your RT task looks as follows:
> void rx_task(void *cookie)
> {
> j=0;
> j++;
> while(1);
> }
An endless loop in an RT task ... no good idea.
--
Sebastian
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-06-24 13:16 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-24 12:36 [Xenomai-help] error creating a task with rt_task_spawn Karl Reichert
2008-06-24 12:50 ` Sebastian Smolorz
2008-06-24 13:00 ` Karl Reichert
2008-06-24 13:16 ` Sebastian Smolorz
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.