Skip to contentSkip to conversation

Problems with rt_task_create and rt_task_join

Xenomai-help Mauro Salvini 2 participants 2 messages Feb 11, 2011 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 8701358.01297411757328.JavaMail.SYSTEM@pc-msalvini

#1 lore raw
Quoted 7 lines

Well, looking at the code, this should not happen. The question is: how do you ensure, in the code that calls rt_task_join, that the thread being created had the time to call rt_task_shadow? In other words, are you sure that you are not passing rt_task_join an uninitialized RT_TASK?

So, as usual, we are missing a simple standalone test showing the issue you have.

There was a subtle bug that realizes exactly what you explained, thank you!
Question is: after a successful rt_task_shadow() call done by a pthread, we can forget that this rt-task was created as pthread and then we must handle it with rt_task_* procedures, is it right? In other words, does pthread become a RT_TASK at all, as if it was created with rt_task_create()?

Thanks again, Gilles.

#2 lore raw
Quoted 11 lines · Mauro Salvini
Quoted 8 lines

Well, looking at the code, this should not happen. The question is:
how do you ensure, in the code that calls rt_task_join, that the thread being created had the time to call rt_task_shadow? In other words, are you sure that you are not passing rt_task_join an uninitialized RT_TASK?

So, as usual, we are missing a simple standalone test showing the issue you have.

There was a subtle bug that realizes exactly what you explained, thank you!

This is not exactly a subtle bug.

Quoted 5 lines

Question is: after a successful rt_task_shadow() call done by a pthread, we can forget that this rt-task was created as pthread and then we must handle it with rt_task_* procedures, is it right? In other words, does pthread become a RT_TASK at all, as if it was created with rt_task_create()?

No, an RT_TASK is also a pthread, whether created with rt_task_shadow or rt_task_create (if you look at src/skins/native/task.c, you will see that rt_task_create creates a thread with pthread_create which does the same thing as rt_task_shadow). You saw that rt_task_join was using pthread_join under the hood. And by the way, rt_task_shadow by itself is mainly useful for turning the main thread into an RT_TASK, it is simpler to create other RT_TASKs with rt_task_create.

Signature · 1 line
					    Gilles.