Skip to contentSkip to conversation

error creating a task with rt_task_spawn

Xenomai-help Karl Reichert 2 participants 4 messages Jun 24, 2008

lore
Share & tools
lore
#0 lore raw

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);
}
Signature · 1 line
von Karl Reichert
#1 lore raw
Quoted 15 lines · Karl Reichert

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>

Quoted 2 lines

int i,j,x;
RT_TASK *rx_tsk;

This is a (uninitialized) pointer ...
Maybe you wanted to type
RT_TASK rx_tsk;
?

Quoted 11 lines

int ret1;
int ret2;

void rx_task(void *cookie);
void cleanup(int dummy);

int main (int argc, char* argv[])

{
	i = 0;
Quoted 6 lines
   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.

Signature · 1 line
Sebastian
#2 lore raw
Quoted 41 lines
Quoted 3 lines · Karl Reichert

Hello,

I'm trying to create and start a new thread via rt_task_spawn() but I

always get error -3. ("Unknown error: -3")

Quoted 12 lines

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>

Quoted 2 lines

int i,j,x;
RT_TASK *rx_tsk;

This is a (uninitialized) pointer ...
Maybe you wanted to type
RT_TASK rx_tsk;
?

Quoted 16 lines

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;
   }
Quoted 5 lines
Quoted 1 line
	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

Signature · 1 line
von Karl Reichert
#3 lore raw
Quoted 8 lines · Karl Reichert

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:

Quoted 6 lines

void rx_task(void *cookie)

{
	j=0;
	j++;
	while(1);
}

An endless loop in an RT task ... no good idea.

Signature · 1 line
Sebastian