Force switch back to primary domain
Hi all,
my scenario is as follows:
- Xenomai 2.4.10, Linux 2.6.30.10
- rtdm-driver, defining ioctl_rt and ioctl_nrt
- user space task migrated with rt_task_shadow() to primary domain
- user space task is in a loop calling rt_dev_ioctl()
what happens:
as long as user space task does not switch to secondary domain user space task comes into ioctl_rt of my driver, which waits on an event with rtdm_event_wait() - fine :-)
but, when user space task gets a Linux signal (SIGTRAP caused by breakpoint), user space task switches to secondary domain executing the signal handler, which returns after handling the signal - fine up to here.
then, i would like to switch back to primary domain using:
rt_task_set_mode(0, T_PRIMARY, NULL);
which returns without error. but, when calling rt_dev_ioctl() again, the non realtime version function of the driver ioctl_nrt is called (where i can't use rtdm_event_wait()).
tried to rt_task_sleep(1000000000) and calling rt_task_set_mode() again, no success, seems like user space thread is locked into secondary domain, why?
How can i force to switch a thread back into primary mode again?
Thanks for your help,
Olli
Quoted 5 lines · Tschaeche IT-Services
Hi all,
my scenario is as follows:
- Xenomai 2.4.10, Linux 2.6.30.10
It would be nice if you could try Xenomai 2.5.1, the latest stable release, to see if you are not having a problem that we already fixed.
Quoted 12 lines
- rtdm-driver, defining
ioctl_rtandioctl_nrt
- user space task migrated withrt_task_shadow()to primary domain
- user space task is in a loop callingrt_dev_ioctl()what happens:
as long as user space task does not switch to secondary domain user space task comes into
ioctl_rtof my driver, which waits on an event withrtdm_event_wait()- fine :-)
Quoted 8 lines
but, when user space task gets a Linux signal (SIGTRAP caused by breakpoint), user space task switches to secondary domain executing the signal handler, which returns after handling the signal - fine up to here.
then, i would like to switch back to primary domain using:
rt_task_set_mode(0, T_PRIMARY, NULL);
You do not need to do that.
Quoted 4 lines
which returns without error. but, when calling
rt_dev_ioctl()again, the non realtime version function of the driverioctl_nrtis called (where i can't usertdm_event_wait()).
in ioctl_nrt, return -ENOSYS, Xenomai will switch back your task to primary mode, and call the rt ioctl.
Signature · 4 lines
Gilles Chanteperdrix, Free Electrons Kernel, drivers, real-time and embedded Linux development, consulting, training and support. http://free-electrons.com
Hi,
Quoted 2 lines · Gilles Chanteperdrix
It would be nice if you could try Xenomai 2.5.1, the latest stable release, to see if you are not having a problem that we already fixed.
it seems as we (Henri and me) have problems with the mutex implementation (FAST_SYNC) in 2.5.1. we'll try and give you feedback when we have time to debug this issue.
Quoted 6 lines
Quoted 3 lines
which returns without error. but, when calling
rt_dev_ioctl()again, the non realtime version function of the driverioctl_nrtis called (where i can't usertdm_event_wait()).in
ioctl_nrt, return-ENOSYS, Xenomai will switch back your task to primary mode, and call the rt ioctl.
great - that's what a was looking for!
Thank you,
Olli
Signature · 4 lines
Tschaeche IT-Services Tel.: +49/9134/9089850 Dr.-Ing. Oliver Tschäche Mobil: +49/176/20435601 Welluckenweg 4 Email: [email protected] 91077 Neunkirchen
Quoted 9 lines · Tschaeche IT-Services
Hi,
Quoted 2 lines · Gilles Chanteperdrix
It would be nice if you could try Xenomai 2.5.1, the latest stable release, to see if you are not having a problem that we already fixed.
it seems as we (Henri and me) have problems with the mutex implementation (
FAST_SYNC) in 2.5.1. we'll try and give you feedback when we have time to debug this issue.
If you have a test program which fails, just send that, we will try and sort it out.
Signature · 4 lines
Gilles Chanteperdrix, Free Electrons Kernel, drivers, real-time and embedded Linux development, consulting, training and support. http://free-electrons.com
Quoted 2 lines · Gilles Chanteperdrix
If you have a test program which fails, just send that, we will try and sort it out.
failed to pin and separate the critical section of code from our application - yet. thus, might be a bug in our application. currently working on other issues :-( we'll let you know, as soon as we experience any progress.
thanks for your support,
Olli
Unfortunately I was not able to capture the problem in a basic application :-( and I cannot sent our full application as is. It is easy to reproduce with our app.
But... As a quick (quick?!) test I disabled CONFIG_XENO_FASTSYNCH. Then I could not reproduce the problem anymore. So it I guess it is somewhere in that area...
We use the rt_mutex implementation from the Xenomai native skin from user space.
Quoted 25 lines · Gilles Chanteperdrix
Quoted 9 lines · Tschaeche IT-Services
Hi,
Quoted 2 lines · Gilles Chanteperdrix
It would be nice if you could try Xenomai 2.5.1, the latest stable release, to see if you are not having a problem that we already fixed.
it seems as we (Henri and me) have problems with the mutex implementation (
FAST_SYNC) in 2.5.1. we'll try and give you feedback when we have time to debug this issue.If you have a test program which fails, just send that, we will try and sort it out.
--
Gilles Chanteperdrix, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com_______________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help
Quoted 9 lines · Henri Roosen
Unfortunately I was not able to capture the problem in a basic application :-( and I cannot sent our full application as is. It is easy to reproduce with our app.
But... As a quick (quick?!) test I disabled
CONFIG_XENO_FASTSYNCH. Then I could not reproduce the problem anymore. So it I guess it is somewhere in that area...We use the
rt_muteximplementation from the Xenomai native skin from user space.
Maybe you could tell us on what platform you get the problem, and what is the problem exactly? Does the mutex-torture-native unit test run fine?
It is very important for us to fix this ASAP, we can not afford to let people know the bug exist and do nothing.
Signature · 4 lines
Gilles Chanteperdrix, Free Electrons Kernel, drivers, real-time and embedded Linux development, consulting, training and support. http://free-electrons.com
Quoted 9 lines · Gilles Chanteperdrix
Quoted 8 lines · Henri Roosen
Unfortunately I was not able to capture the problem in a basic application :-( and I cannot sent our full application as is. It is easy to reproduce with our app.
But... As a quick (quick?!) test I disabled
CONFIG_XENO_FASTSYNCH. Then I could not reproduce the problem anymore. So it I guess it is somewhere in that area...
Quoted 7 lines
Quoted 1 line
We use the
rt_muteximplementation from the Xenomai native skin from user space.Maybe you could tell us on what platform you get the problem, and what is the problem exactly? Does the mutex-torture-native unit test run fine?
It is very important for us to fix this ASAP, we can not afford to let people know the bug exist and do nothing.
Full ack from my side. We are running this on big-iron x86-64, so far without problems. If there is an issue, we would be happy to know more about it to start digging after the reason.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
We run on x86.
I agree it is important to fix issues ASAP. It helps all of us. However, I am not sure it is a Xenomai problem. The mutex-torture-native runs fine, as well as the other Xenomai test apps.
I ran into the a mutex issue when using git version 51adc67cd1d4128c62050ea647c074066a5f3c83 (=2.5.0++). Then I traced it to a mutex_acquire that blocked the system, even though the mutex was not acquired by anyone. And I noticed the app would run again when switching off the FASTSYNC. We could not explain why it locked up. Seemed very strange and probably our own app's issue.
Even though it was likely to be our own apps issue, we decided to leave the 2.5.x branch and base our development on the 2.4.x branch. Our app runs fine on that branch with respect to Xenomai.
I just compiled our app against the 2.5.1 and noticed the application behaves different again from the git version I tried before. I'm not sure if it is the mutex problem but it locks up earlier than before. Fact is our app has a problem with 2.5.x branch and like I said
before: very likely the issue is in our own app.
Unfortunately currently we get no time to investigate 2.5.x because of project pressure and deadlines :-(. Although personally I think it would be wise to investigate, for our own good! I'll try to find some spare time to investigate further.
I will keep the mailinglist posted, but I don't think there is a reason to worry...
Thanks,
Henri.
Quoted 28 lines · Jan Kiszka
Quoted 9 lines · Gilles Chanteperdrix
Quoted 8 lines · Henri Roosen
Unfortunately I was not able to capture the problem in a basic application :-( and I cannot sent our full application as is. It is easy to reproduce with our app.
But... As a quick (quick?!) test I disabled
CONFIG_XENO_FASTSYNCH. Then I could not reproduce the problem anymore. So it I guess it is somewhere in that area...Quoted 7 lines
Quoted 1 line
We use the
rt_muteximplementation from the Xenomai native skin from user space.Maybe you could tell us on what platform you get the problem, and what is the problem exactly? Does the mutex-torture-native unit test run fine?
It is very important for us to fix this ASAP, we can not afford to let people know the bug exist and do nothing.
Full ack from my side. We are running this on big-iron x86-64, so far without problems. If there is an issue, we would be happy to know more about it to start digging after the reason.
Jan
--
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
Quoted 24 lines · Henri Roosen
We run on x86.
I agree it is important to fix issues ASAP. It helps all of us. However, I am not sure it is a Xenomai problem. The mutex-torture-native runs fine, as well as the other Xenomai test apps.
I ran into the a mutex issue when using git version
51adc67cd1d4128c62050ea647c074066a5f3c83(=2.5.0++). Then I traced it to amutex_acquirethat blocked the system, even though the mutex was not acquired by anyone. And I noticed the app would run again when switching off the FASTSYNC. We could not explain why it locked up. Seemed very strange and probably our own app's issue.Even though it was likely to be our own apps issue, we decided to leave the 2.5.x branch and base our development on the 2.4.x branch. Our app runs fine on that branch with respect to Xenomai.
I just compiled our app against the 2.5.1 and noticed the application behaves different again from the git version I tried before. I'm not sure if it is the mutex problem but it locks up earlier than before. Fact is our app has a problem with 2.5.x branch and like I said
before: very likely the issue is in our own app.
Quoted 7 lines
Unfortunately currently we get no time to investigate 2.5.x because of project pressure and deadlines :-(. Although personally I think it would be wise to investigate, for our own good! I'll try to find some spare time to investigate further.
I will keep the mailinglist posted, but I don't think there is a reason to worry...
Ok. Could you tell us on which platform you have these issues?
Signature · 4 lines
Gilles Chanteperdrix, Free Electrons Kernel, drivers, real-time and embedded Linux development, consulting, training and support. http://free-electrons.com
We run on an x86 (32bit) system on chip (VortexDX chip).
Quoted 41 lines · Gilles Chanteperdrix
Quoted 24 lines · Henri Roosen
We run on x86.
I agree it is important to fix issues ASAP. It helps all of us. However, I am not sure it is a Xenomai problem. The mutex-torture-native runs fine, as well as the other Xenomai test apps.
I ran into the a mutex issue when using git version
51adc67cd1d4128c62050ea647c074066a5f3c83(=2.5.0++). Then I traced it to amutex_acquirethat blocked the system, even though the mutex was not acquired by anyone. And I noticed the app would run again when switching off the FASTSYNC. We could not explain why it locked up. Seemed very strange and probably our own app's issue.Even though it was likely to be our own apps issue, we decided to leave the 2.5.x branch and base our development on the 2.4.x branch. Our app runs fine on that branch with respect to Xenomai.
I just compiled our app against the 2.5.1 and noticed the application behaves different again from the git version I tried before. I'm not sure if it is the mutex problem but it locks up earlier than before. Fact is our app has a problem with 2.5.x branch and like I said
before: very likely the issue is in our own app.Quoted 7 lines
Unfortunately currently we get no time to investigate 2.5.x because of project pressure and deadlines :-(. Although personally I think it would be wise to investigate, for our own good! I'll try to find some spare time to investigate further.
I will keep the mailinglist posted, but I don't think there is a reason to worry...
Ok. Could you tell us on which platform you have these issues?
--
Gilles Chanteperdrix, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
Quoted 1 line · Henri Roosen
We run on an x86 (32bit) system on chip (VortexDX chip).
I could not find the sources for the vortexDX kernel, do they exist, or are you using a generic x86 configuration?
Signature · 1 line
Gilles.
Quoted 5 lines · Gilles Chanteperdrix
Quoted 1 line · Henri Roosen
We run on an x86 (32bit) system on chip (VortexDX chip).
I could not find the sources for the vortexDX kernel, do they exist, or are you using a generic x86 configuration?
To my knowledge, this thing is supposed to work with generic, though pre-historic (PIT/PIC), settings.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
It is a generic x86 configuration. Please find attached the .config file we use.
And note that I still think it is a problem in our application... I have the feeling there is a problem around our mutex initialization code. I might find some time this evening to dig into it a little...
Thanks,
Henri
Quoted 16 lines · Jan Kiszka
Quoted 5 lines · Gilles Chanteperdrix
Quoted 1 line · Henri Roosen
We run on an x86 (32bit) system on chip (VortexDX chip).
I could not find the sources for the vortexDX kernel, do they exist, or are you using a generic x86 configuration?
To my knowledge, this thing is supposed to work with generic, though pre-historic (PIT/PIC), settings.
Jan
--
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
Ok, found some time to investigate the mutex problem we see on 2.5.1.
I managed to reproduce with a basic app that uses the same way of thread creation as we have in our app.
Please find attached the basic app. Note, it runs fine on Xenomai 2.4.10. Fails on 2.5.1.
Also, the problem does not show when creating the threads with rt_task_create.
So the main question is, should it be possible to create threads with the clone() system call and then shadowing the threads into the Xenomai domain with rt_task_shadow()? And are we just lucky it runs this way in 2.4.10?
Thanks,
Henri.
Quoted 27 lines · Henri Roosen
It is a generic x86 configuration. Please find attached the .config file we use.
And note that I still think it is a problem in our application... I have the feeling there is a problem around our mutex initialization code. I might find some time this evening to dig into it a little...
Thanks,
HenriQuoted 16 lines · Jan Kiszka
Quoted 5 lines · Gilles Chanteperdrix
Quoted 1 line · Henri Roosen
We run on an x86 (32bit) system on chip (VortexDX chip).
I could not find the sources for the vortexDX kernel, do they exist, or are you using a generic x86 configuration?
To my knowledge, this thing is supposed to work with generic, though pre-historic (PIT/PIC), settings.
Jan
--
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/mman.h> /* Needed for mlockall() */
#include <limits.h>
#include <native/task.h>
#include <native/mutex.h>
#include <sched.h>
#define NUM_THREADS 2
#define MY_STACK_SIZE (100*1024) /* 100 kB is enough for now. */
static RT_TASK rt_task_desc[NUM_THREADS];
static RT_MUTEX mutex;
static int wait0 = 1;
static int wait1 = 1;
static char *stack0;
static char *stack1;
#define MAIN_TASK_PRIO 4
#define THREAD_PRIO 3
#define PRNT(s) fprintf(stderr, s); fflush(stderr)
int handler0(void *cookie)
{
if (rt_task_shadow(&rt_task_desc[0], "thread0", THREAD_PRIO, 0)) {
PRNT("! ERROR shadow 1\n");
exit(EXIT_FAILURE);
}
PRNT("handler0 started\n");
while (wait0) {
PRNT("->0\n");
if (rt_mutex_acquire(&mutex, TM_INFINITE)) {
PRNT("! ERROR acc 0\n");
exit(EXIT_FAILURE);
}
PRNT("- 0\n");
if (rt_mutex_release(&mutex)) {
PRNT("! ERROR rel 0\n");
exit(EXIT_FAILURE);
}
PRNT("<-0\n");
}
PRNT("handler0 finished\n");
rt_task_delete(NULL);
return 0;
}int handler1(void *cookie)
{
if (rt_task_shadow(&rt_task_desc[1], "thread1", THREAD_PRIO, 0)) {
PRNT("! ERROR shadow 1\n");
exit(EXIT_FAILURE);
}
PRNT("handler1 started\n");
while (wait1) {
PRNT("->1\n");
if (rt_mutex_acquire(&mutex, TM_INFINITE)) {
PRNT("! ERROR acc 1\n");
exit(EXIT_FAILURE);
}
PRNT("- 1\n");
if (rt_mutex_release(&mutex)) {
PRNT("! ERROR rel 1\n");
exit(EXIT_FAILURE);
}
PRNT("<-1\n");
}
PRNT("handler1 finished\n");
rt_task_delete(NULL);
return 0;
}int main(void)
{
mlockall(MCL_CURRENT | MCL_FUTURE);
if (rt_mutex_create(&mutex, "mutex")) {
PRNT("! ERROR create\n");
exit(EXIT_FAILURE);
}
stack0 = (char *)malloc(MY_STACK_SIZE);
stack1 = (char *)malloc(MY_STACK_SIZE);
clone(handler0, stack0 + MY_STACK_SIZE, CLONE_FILES | CLONE_FS |
CLONE_IO | CLONE_SIGHAND | CLONE_VM, NULL);
clone(handler1, stack1 + MY_STACK_SIZE, CLONE_FILES | CLONE_FS |
CLONE_IO | CLONE_SIGHAND | CLONE_VM, NULL);
PRNT("Press <ENTER> to exit\n");
getc(stdin);
wait0 = 0;
wait1 = 0;
PRNT("main finished\n");
return 0;
}Quoted 7 lines · Henri Roosen
Ok, found some time to investigate the mutex problem we see on 2.5.1.
I managed to reproduce with a basic app that uses the same way of thread creation as we have in our app.
Please find attached the basic app. Note, it runs fine on Xenomai 2.4.10. Fails on 2.5.1.
Quoted 6 lines
Also, the problem does not show when creating the threads with
rt_task_create.So the main question is, should it be possible to create threads with the
clone()system call and then shadowing the threads into the Xenomai domain withrt_task_shadow()? And are we just lucky it runs this way in 2.4.10?
I would tend to think that Xenomai relies on the existence of a "pthread_t" associated with each thread, this only happens if the thread is created with pthread_create, not if created with clone.
In fact, I even wonder how it works with 2.4.10.
(rt_task_delete probably does not work in fact).
Signature · 1 line
Gilles.
Quoted 15 lines · Gilles Chanteperdrix
Quoted 7 lines · Henri Roosen
Ok, found some time to investigate the mutex problem we see on 2.5.1.
I managed to reproduce with a basic app that uses the same way of thread creation as we have in our app.
Please find attached the basic app. Note, it runs fine on Xenomai 2.4.10. Fails on 2.5.1.Quoted 6 lines
Also, the problem does not show when creating the threads with
rt_task_create.So the main question is, should it be possible to create threads with the
clone()system call and then shadowing the threads into the Xenomai domain withrt_task_shadow()? And are we just lucky it runs this way in 2.4.10?
Quoted 6 lines
I would tend to think that Xenomai relies on the existence of a "
pthread_t" associated with each thread, this only happens if the thread is created withpthread_create, not if created with clone.In fact, I even wonder how it works with 2.4.10.
(rt_task_deleteprobably does not work in fact).
I think the problem comes from xeno_get_current_mode() or xeno_get_current(). They use pthread services for sure if xenomai user-space is not using __thread. Now, if using __thread, I do not know for sure whether it should be working.
Signature · 1 line
Gilles.
Quoted 7 lines · Henri Roosen
Ok, found some time to investigate the mutex problem we see on 2.5.1.
I managed to reproduce with a basic app that uses the same way of thread creation as we have in our app.
Please find attached the basic app. Note, it runs fine on Xenomai 2.4.10. Fails on 2.5.1.
Quoted 6 lines
Also, the problem does not show when creating the threads with
rt_task_create.So the main question is, should it be possible to create threads with the
clone()system call and then shadowing the threads into the Xenomai domain withrt_task_shadow()? And are we just lucky it runs this way in 2.4.10?
To get __thread working, I think you should pass CLONE_SETTLS to clone, with something as the tls argument. But what to pass probably depends on the internals of the glibc. I would also pass CLONE_THREAD, since you want to create a thread in the same thread groups as other threads.
Signature · 1 line
Gilles.
Hi Gilles,
Thanks for your support on this! We changed our application so it uses the pthread library to create threads. Just to be on the safe side. And I can confirm this works now on Xenomai 2.5.1.
Might be a good idea to change the documentation of rt_task_shadow what the requirements are for a task to be shadowed. Because "the calling regular Linux task" does not apply anymore for Xenomai 2.5.x.
Thanks,
Henri.
Quoted 24 lines · Gilles Chanteperdrix
Quoted 7 lines · Henri Roosen
Ok, found some time to investigate the mutex problem we see on 2.5.1.
I managed to reproduce with a basic app that uses the same way of thread creation as we have in our app.
Please find attached the basic app. Note, it runs fine on Xenomai 2.4.10. Fails on 2.5.1.Quoted 6 lines
Also, the problem does not show when creating the threads with
rt_task_create.So the main question is, should it be possible to create threads with the
clone()system call and then shadowing the threads into the Xenomai domain withrt_task_shadow()? And are we just lucky it runs this way in 2.4.10?To get
__threadworking, I think you should passCLONE_SETTLSto clone, with something as the tls argument. But what to pass probably depends on the internals of the glibc. I would also passCLONE_THREAD, since you want to create a thread in the same thread groups as other threads.--
Gilles.
Quoted 9 lines · Henri Roosen
Hi Gilles,
Thanks for your support on this! We changed our application so it uses the pthread library to create threads. Just to be on the safe side. And I can confirm this works now on Xenomai 2.5.1.
Might be a good idea to change the documentation of
rt_task_shadowwhat the requirements are for a task to be shadowed. Because "the calling regular Linux task" does not apply anymore for Xenomai 2.5.x.
Just to understand the original motivation: what use case was behind home-brewed thread creation? Note that it's a bit uncommon and can cause troubles all around once you start using libpthread directly - or indirectly.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Quoted 10 lines · Henri Roosen
Hi Gilles,
Thanks for your support on this! We changed our application so it uses the pthread library to create threads. Just to be on the safe side. And I can confirm this works now on Xenomai 2.5.1.
Might be a good idea to change the documentation of
rt_task_shadowwhat the requirements are for a task to be shadowed. Because "the calling regular Linux task" does not apply anymore for Xenomai 2.5.x.
It actually never applied to any Xenomai release. Having the thread created by the standard POSIX call has always been assumed by the libraries (and by myself in the first place).
Quoted 34 lines
Thanks,
Henri.Quoted 15 lines · Gilles Chanteperdrix
Quoted 7 lines · Henri Roosen
Ok, found some time to investigate the mutex problem we see on 2.5.1.
I managed to reproduce with a basic app that uses the same way of thread creation as we have in our app.
Please find attached the basic app. Note, it runs fine on Xenomai 2.4.10. Fails on 2.5.1.Quoted 6 lines
Also, the problem does not show when creating the threads with
rt_task_create.So the main question is, should it be possible to create threads with the
clone()system call and then shadowing the threads into the Xenomai domain withrt_task_shadow()? And are we just lucky it runs this way in 2.4.10?Quoted 9 lines
To get
__threadworking, I think you should passCLONE_SETTLSto clone, with something as the tls argument. But what to pass probably depends on the internals of the glibc. I would also passCLONE_THREAD, since you want to create a thread in the same thread groups as other threads.--
Gilles._______________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help
Signature · 1 line
Philippe.
I am not sure why our application used the clone() system call directly. And because we didn't find a reason why not to use the pthread_create(), we already decided to convert our application to use pthread_create() instead.
However, we didn't run into any problems when using the clone() calls while still on the Xenomai 2.4.x branch. I couldn't find a clear statement in the rt_task_shadow documentation about assuming threads created by libpthread and I assumed that a thread created with clone() would also be "a regular Linux task".
So don't get me wrong, I have no problem with Xenomai assuming threads to be created with libpthread! It is just that we would have removed the clone() call much earlier when the documentation at rt_task_shadow would have been more clear on this.
We have learned this now, but enhancing the documentation might prevent these misunderstandings.
Thanks,
Henri.
Quoted 58 lines · Philippe Gerum
Quoted 10 lines · Henri Roosen
Hi Gilles,
Thanks for your support on this! We changed our application so it uses the pthread library to create threads. Just to be on the safe side. And I can confirm this works now on Xenomai 2.5.1.
Might be a good idea to change the documentation of
rt_task_shadowwhat the requirements are for a task to be shadowed. Because "the calling regular Linux task" does not apply anymore for Xenomai 2.5.x.It actually never applied to any Xenomai release. Having the thread created by the standard POSIX call has always been assumed by the libraries (and by myself in the first place).
Quoted 26 lines
Thanks,
Henri.Quoted 21 lines · Gilles Chanteperdrix
Quoted 7 lines · Henri Roosen
Ok, found some time to investigate the mutex problem we see on 2.5.1.
I managed to reproduce with a basic app that uses the same way of thread creation as we have in our app.
Please find attached the basic app. Note, it runs fine on Xenomai 2.4.10. Fails on 2.5.1.Quoted 6 lines
Also, the problem does not show when creating the threads with
rt_task_create.So the main question is, should it be possible to create threads with the
clone()system call and then shadowing the threads into the Xenomai domain withrt_task_shadow()? And are we just lucky it runs this way in 2.4.10?To get
__threadworking, I think you should passCLONE_SETTLSto clone, with something as the tls argument. But what to pass probably depends on the internals of the glibc. I would also passCLONE_THREAD, since you want to create a thread in the same thread groups as other threads.Quoted 8 lines
Quoted 3 lines
--
Gilles._______________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help--
Philippe.
Quoted 11 lines · Henri Roosen
I am not sure why our application used the
clone()system call directly. And because we didn't find a reason why not to use thepthread_create(), we already decided to convert our application to usepthread_create()instead.However, we didn't run into any problems when using the
clone()calls while still on the Xenomai 2.4.x branch. I couldn't find a clear statement in thert_task_shadowdocumentation about assuming threads created by libpthread and I assumed that a thread created withclone()would also be "a regular Linux task".
Quoted 4 lines
So don't get me wrong, I have no problem with Xenomai assuming threads to be created with libpthread! It is just that we would have removed the
clone()call much earlier when the documentation atrt_task_shadowwould have been more clear on this.
No problem. I'm just stressing the fact that all skins may depend on POSIX bits internally (such as having valid pthread_t identifier), so pthread_create() is definitely the way to go.
Quoted 4 lines
We have learned this now, but enhancing the documentation might prevent these misunderstandings.
Probably, yes.
Quoted 62 lines
Thanks,
Henri.Quoted 58 lines · Philippe Gerum
Quoted 10 lines · Henri Roosen
Hi Gilles,
Thanks for your support on this! We changed our application so it uses the pthread library to create threads. Just to be on the safe side. And I can confirm this works now on Xenomai 2.5.1.
Might be a good idea to change the documentation of
rt_task_shadowwhat the requirements are for a task to be shadowed. Because "the calling regular Linux task" does not apply anymore for Xenomai 2.5.x.It actually never applied to any Xenomai release. Having the thread created by the standard POSIX call has always been assumed by the libraries (and by myself in the first place).
Quoted 26 lines
Thanks,
Henri.Quoted 21 lines · Gilles Chanteperdrix
Quoted 7 lines · Henri Roosen
Ok, found some time to investigate the mutex problem we see on 2.5.1.
I managed to reproduce with a basic app that uses the same way of thread creation as we have in our app.
Please find attached the basic app. Note, it runs fine on Xenomai 2.4.10. Fails on 2.5.1.Quoted 6 lines
Also, the problem does not show when creating the threads with
rt_task_create.So the main question is, should it be possible to create threads with the
clone()system call and then shadowing the threads into the Xenomai domain withrt_task_shadow()? And are we just lucky it runs this way in 2.4.10?To get
__threadworking, I think you should passCLONE_SETTLSto clone, with something as the tls argument. But what to pass probably depends on the internals of the glibc. I would also passCLONE_THREAD, since you want to create a thread in the same thread groups as other threads.Quoted 8 lines
Quoted 3 lines
--
Gilles._______________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help--
Philippe.
Signature · 1 line
Philippe.