Skip to contentSkip to conversation

rt_task_self() return value

DISCUSSION Mauro Salvini 2 participants 6 messages Nov 19, 2019

lore
Share & tools
lore
#0 lore raw

Hi all,

I'm using Xenomai 3.0.9 in cobalt mode and I'm facing an issue on rt_task_self() returned value.

Please see this simple code:

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <alchemy/task.h>

RT_TASK gNewTask;

static void Task(void *lpArgument)

{
	rt_printf("Task created.\n");
	gNewTask = *(rt_task_self());
}

int main()

{
	RT_TASK tNewTask;
	int err = rt_task_create(&tNewTask, "TEST", 16384, 10,
T_JOINABLE);
	rt_printf(" task create: %d\n", err);
	err = rt_task_start(&tNewTask, Task, NULL);
	rt_printf(" task start: %d\n", err);
	
	rt_task_sleep(2000000000);

	//err = rt_task_join(&tNewTask);
	err = rt_task_join(&gNewTask);
	rt_printf(" task join : %d\n", err);

	return 0;
}

Code is compiled using xeno-config --alchemy.

Using the rt_task_self() returned value with rt_task_join(), the latter returns -ESRCH (no such process). Obviously if I use the local tNewTask variable, return value is 0.

I'm pretty sure that this works without errors with Xenomai2.

Is it the expected behavior with Xenomai3?

Thanks in advance, regards

Signature · 1 line
Mauro
#1 lore raw
Quoted 12 lines · Mauro Salvini via Xenomai

Hi all,

I'm using Xenomai 3.0.9 in cobalt mode and I'm facing an issue on rt_task_self() returned value.

Please see this simple code:

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <alchemy/task.h>

Quoted 6 lines

RT_TASK gNewTask;

static void Task(void *lpArgument)

{
	rt_printf("Task created.\n");
	gNewTask = *(rt_task_self());

This fills the internal data structure RT_TASK with the content of another one. Rather than "cloning", did you try using a reference as the API suggests? If that worked in Xenomai 2, it was luck.

Jan

Quoted 32 lines

}

int main()

{
	RT_TASK tNewTask;
	int err = rt_task_create(&tNewTask, "TEST", 16384, 10,
T_JOINABLE);
	rt_printf(" task create: %d\n", err);
	err = rt_task_start(&tNewTask, Task, NULL);
	rt_printf(" task start: %d\n", err);
	
	rt_task_sleep(2000000000);

	//err = rt_task_join(&tNewTask);
	err = rt_task_join(&gNewTask);
	rt_printf(" task join : %d\n", err);

	return 0;
}

Code is compiled using xeno-config --alchemy.

Using the rt_task_self() returned value with rt_task_join(), the latter returns -ESRCH (no such process). Obviously if I use the local tNewTask variable, return value is 0.

I'm pretty sure that this works without errors with Xenomai2.

Is it the expected behavior with Xenomai3?

Thanks in advance, regards

Signature · 2 lines
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux
#2 lore raw
Quoted 20 lines · Jan Kiszka
Quoted 12 lines · Mauro Salvini via Xenomai

Hi all,

I'm using Xenomai 3.0.9 in cobalt mode and I'm facing an issue on rt_task_self() returned value.

Please see this simple code:

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <alchemy/task.h>

Quoted 6 lines

RT_TASK gNewTask;

static void Task(void *lpArgument)

{
	rt_printf("Task created.\n");
	gNewTask = *(rt_task_self());
Quoted 5 lines

This fills the internal data structure RT_TASK with the content of another one. Rather than "cloning", did you try using a reference as the
API suggests? If that worked in Xenomai 2, it was luck.

Hi Jan,

thanks for your answer.
Yes, I tried it and even does not work. Changing code in this way:

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <alchemy/task.h>

RT_TASK* gNewTask;

static void Task(void *lpArgument)
{
        rt_printf("Task created.\n");
        gNewTask = rt_task_self();
}

int main()
{
        RT_TASK tNewTask;
        int err = rt_task_create(&tNewTask, "TEST", 16384, 10, T_JOINABLE);
        rt_printf(" task create: %d\n", err);
        err = rt_task_start(&tNewTask, Task, NULL); rt_printf(" task start: %d\n", err);

        rt_task_sleep(2000000000);

        //err = rt_task_join(&tNewTask);
        err = rt_task_join(gNewTask);
        rt_printf(" task join : %d\n", err);

        return 0;
}

returns:

./test
 task create: 0
Task created.
 task start: 0
 task join : -3

Thanks, regards

-- Mauro

#3 lore raw
Quoted 63 lines · Mauro Salvini
Quoted 20 lines · Jan Kiszka
Quoted 12 lines · Mauro Salvini via Xenomai

Hi all,

I'm using Xenomai 3.0.9 in cobalt mode and I'm facing an issue on rt_task_self() returned value.

Please see this simple code:

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <alchemy/task.h>

Quoted 6 lines

RT_TASK gNewTask;

static void Task(void *lpArgument)

{
	rt_printf("Task created.\n");
	gNewTask = *(rt_task_self());
Quoted 5 lines

This fills the internal data structure RT_TASK with the content of another one. Rather than "cloning", did you try using a reference as the
API suggests? If that worked in Xenomai 2, it was luck.

Hi Jan,

thanks for your answer.
Yes, I tried it and even does not work. Changing code in this way:

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <alchemy/task.h>

RT_TASK* gNewTask;

static void Task(void *lpArgument)
{
        rt_printf("Task created.\n");
        gNewTask = rt_task_self();
}

int main()
{
        RT_TASK tNewTask;
        int err = rt_task_create(&tNewTask, "TEST", 16384, 10,
T_JOINABLE);
        rt_printf(" task create: %d\n", err);
        err = rt_task_start(&tNewTask, Task, NULL); rt_printf(" task start: %d\n", err);

        rt_task_sleep(2000000000);

        //err = rt_task_join(&tNewTask);
        err = rt_task_join(gNewTask);
        rt_printf(" task join : %d\n", err);

        return 0;
}

Quoted 8 lines

returns:

./test
 task create: 0
Task created.
 task start: 0
 task join : -3

OK, then we have a regression. Let me check...

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux
#4 lore raw
Quoted 76 lines · Jan Kiszka
Quoted 66 lines · Mauro Salvini
Quoted 21 lines · Jan Kiszka
Quoted 13 lines · Mauro Salvini via Xenomai

Hi all,

I'm using Xenomai 3.0.9 in cobalt mode and I'm facing an issue on
rt_task_self() returned value.

Please see this simple code:

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <alchemy/task.h>

Quoted 6 lines

RT_TASK gNewTask;

static void Task(void *lpArgument)

{
	rt_printf("Task created.\n");
	gNewTask = *(rt_task_self());
Quoted 7 lines

This fills the internal data structure RT_TASK with the content of
another one. Rather than "cloning", did you try using a reference as
the
API suggests? If that worked in Xenomai 2, it was luck.

Hi Jan,

thanks for your answer.
Yes, I tried it and even does not work. Changing code in this way:

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <alchemy/task.h>

RT_TASK* gNewTask;

static void Task(void *lpArgument)
{
         rt_printf("Task created.\n");
         gNewTask = rt_task_self();
}

int main()
{
         RT_TASK tNewTask;
         int err = rt_task_create(&tNewTask, "TEST", 16384, 10, T_JOINABLE);
         rt_printf(" task create: %d\n", err);
         err = rt_task_start(&tNewTask, Task, NULL); rt_printf(" task start: %d\n", err);

         rt_task_sleep(2000000000);

         //err = rt_task_join(&tNewTask);
         err = rt_task_join(gNewTask);
         rt_printf(" task join : %d\n", err);

         return 0;
}

Quoted 8 lines

returns:

./test
  task create: 0
Task created.
  task start: 0
  task join : -3

Quoted 4 lines

OK, then we have a regression. Let me check...

Jan

Thank you Jan for the patch.

Regards

Signature · 1 line
Mauro
#5 lore raw
Quoted 77 lines · Mauro Salvini
Quoted 76 lines · Jan Kiszka
Quoted 74 lines · Mauro Salvini
Quoted 21 lines · Jan Kiszka
Quoted 13 lines · Mauro Salvini via Xenomai

Hi all,

I'm using Xenomai 3.0.9 in cobalt mode and I'm facing an issue on
rt_task_self() returned value.

Please see this simple code:

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <alchemy/task.h>

Quoted 6 lines

RT_TASK gNewTask;

static void Task(void *lpArgument)

{
	rt_printf("Task created.\n");
	gNewTask = *(rt_task_self());
Quoted 7 lines

This fills the internal data structure RT_TASK with the content of
another one. Rather than "cloning", did you try using a reference as
the
API suggests? If that worked in Xenomai 2, it was luck.

Hi Jan,

thanks for your answer.
Yes, I tried it and even does not work. Changing code in this way:

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <alchemy/task.h>

RT_TASK* gNewTask;

static void Task(void *lpArgument)
{
         rt_printf("Task created.\n");
         gNewTask = rt_task_self();
}

int main()
{
         RT_TASK tNewTask;
         int err = rt_task_create(&tNewTask, "TEST", 16384, 10,
T_JOINABLE);
         rt_printf(" task create: %d\n", err);
         err = rt_task_start(&tNewTask, Task, NULL); rt_printf(" task start: %d\n", err);

         rt_task_sleep(2000000000);

         //err = rt_task_join(&tNewTask);
         err = rt_task_join(gNewTask);
         rt_printf(" task join : %d\n", err);

         return 0;
}

returns:

./test
  task create: 0
Task created.
  task start: 0
  task join : -3

Quoted 6 lines
Quoted 4 lines

OK, then we have a regression. Let me check...

Jan

Thank you Jan for the patch.

BTW, I only tested the pointer case, but copying the content of RT_TASK should actually work as well.

Thanks for reporting!

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux