rt_task_wait_period() does not return -EWOULDBLOCK
Hi,
I'm facing an unexpected behavior of rt_task_wait_period().
xenomai: 3.0.3
ipipe: 4.1.18-arm-9 on kernel 4.1.36 from NXP
arch: ARM
SOC: iMX6sx
Running simple attached program (compiled and linked using "xeno-config --alchemy --cflags" and "xeno-config --alchemy --ldflags"), rt_task_wait_period() never returns (instead return -EWOULDBLOCK) if rt_task_set_period() not called.
Output with SET_PERIOD defined:
Main 0
WAIT PERIOD DONE!
WAIT PERIOD DONE!
Main 2
WAIT PERIOD DONE!
WAIT PERIOD DONE!
Main 4
WAIT PERIOD DONE!
WAIT PERIOD DONE!
Main 6
...
Output with SET_PERIOD not defined:
Main 0
Main 0
Main 0
Main 0
Main 0
...
Tested also with xenomai 3.0.6 from git on latest commit (on same ipipe and kernel).
Am I wrong somewhere?
Thank you, best regards.
Mauro
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_xeno_waitperiod.c
Type: text/x-csrc
Size: 691 bytes
Desc: not available
URL: <http://xenomai.org/pipermail/xenomai/attachments/20180411/bf7b6b1c/attachment.c>
Quoted 35 lines · Mauro Salvini
Hi,
I'm facing an unexpected behavior of
rt_task_wait_period().xenomai: 3.0.3
ipipe: 4.1.18-arm-9 on kernel 4.1.36 from NXP
arch: ARM
SOC: iMX6sxRunning simple attached program (compiled and linked using "xeno-config --alchemy --cflags" and "xeno-config --alchemy --ldflags"),
rt_task_wait_period()never returns (instead return-EWOULDBLOCK) ifrt_task_set_period()not called.Output with
SET_PERIODdefined:
Main 0
WAIT PERIOD DONE!
WAIT PERIOD DONE!
Main 2
WAIT PERIOD DONE!
WAIT PERIOD DONE!
Main 4
WAIT PERIOD DONE!
WAIT PERIOD DONE!
Main 6
...Output with
SET_PERIODnot defined:
Main 0
Main 0
Main 0
Main 0
Main 0
...
Quoted 4 lines
Tested also with xenomai 3.0.6 from git on latest commit (on same ipipe and kernel).
Am I wrong somewhere?
Please try this and let me know if the situation gets any better:
lib/copperplate/threadobj.c +11 -5
@@ -1625,25 +1625,28 @@ int threadobj_set_periodic(struct threadobj *thobj, {/* thobj->lock held */ struct itimerspec its;struct sigevent sev; +timer_t timer;int ret;__threadobj_check_locked (thobj); -if (thobj->periodic_timer ==NULL ) { + timer = thobj->periodic_timer; +if (timer ==NULL ) {memset (&sev,0 ,sizeof (sev)); sev.sigev_signo =SIGPERIOD ; sev.sigev_notify =SIGEV_SIGNAL |SIGEV_THREAD_ID ; sev.sigev_notify_thread_id =threadobj_get_pid (thobj); - ret =__RT (timer_create (CLOCK_COPPERPLATE , &sev, - &thobj->periodic_timer)); + ret =__RT (timer_create (CLOCK_COPPERPLATE , &sev, &timer));if (ret)return __bt (-errno); - } + thobj->periodic_timer = timer; + }else if (!timespec_scalar (idate) && !timespec_scalar (period)) + thobj->periodic_timer =NULL ; its.it_value = *idate; its.it_interval = *period; - ret =__RT (timer_settime (thobj->periodic_timer,TIMER_ABSTIME , &its,NULL )); + ret =__RT (timer_settime (timer,TIMER_ABSTIME , &its,NULL ));if (ret)return __bt (-errno);
@@ -1656,6 +1659,9 @@ int threadobj_wait_period(unsigned long *overruns_r)siginfo_t si;int sig; +if (current->periodic_timer ==NULL ) +return -EWOULDBLOCK ; +for (;;) { current->run_state = __THREAD_S_DELAYED; sig =__RT (sigwaitinfo (&sigperiod_set, &si));
Signature · 1 line
Philippe.
Quoted 6 lines · Philippe Gerum
Quoted 5 lines · Mauro Salvini
Hi,
I'm facing an unexpected behavior of
rt_task_wait_period().
...
Quoted 1 line
Please try this and let me know if the situation gets any better:
Yes, now it works as expected.
Output with SET_PERIOD not defined is:
NON PERIODIC TASK!
Main 0
NON PERIODIC TASK!
NON PERIODIC TASK!
Main 2
NON PERIODIC TASK!
NON PERIODIC TASK!
Main 4
...
Thank you Philippe.
Best regards.
Mauro
Quoted 25 lines · Mauro Salvini
Quoted 6 lines · Philippe Gerum
Quoted 5 lines · Mauro Salvini
Hi,
I'm facing an unexpected behavior of
rt_task_wait_period()....
Quoted 1 line
Please try this and let me know if the situation gets any better:
Yes, now it works as expected.
Output with
SET_PERIODnot defined is:
NON PERIODIC TASK!
Main 0
NON PERIODIC TASK!
NON PERIODIC TASK!
Main 2
NON PERIODIC TASK!
NON PERIODIC TASK!
Main 4
...
Quoted 7 lines
Thank you Philippe.
Best regards.
Mauro
Ok, upstreamed. Thanks.
Signature · 1 line
Philippe.
Quoted 17 lines · Philippe Gerum
Quoted 16 lines · Mauro Salvini
Quoted 6 lines · Philippe Gerum
Quoted 5 lines · Mauro Salvini
Hi,
I'm facing an unexpected behavior of
rt_task_wait_period()....
Quoted 1 line
Please try this and let me know if the situation gets any better:
Yes, now it works as expected.
Thank you Philippe.
Quoted 8 lines
Quoted 5 lines
Best regards.
Mauro
Ok, upstreamed. Thanks.
Hi Philippe,
I resume this thread because when I tried your patch I tried only the case that didn't work, that is with SET_PERIOD undefined (so rt_task_set_periodic() not called), and didn't re-test also the code with rt_task_set_periodic() call. Sorry, my fault.
With this patch applied, when I call rt_task_set_periodic() (SET_PERIOD defined), rt_task_wait_period() returns -EWOULDBLOCK as if rt_task_set_periodic() was never called.
Thanks in advance, regards
Mauro
Oh yes.
I was about to post the similar problem with rt_task_wait_period(NULL).
I did "git pull" for my xenomai-3 repo and installed the newer version. After that weird things started happening to my previous test program for latency measurement.
The latency value started giving all wrong results.
In my test programs I was using: rt_task_set_period(100 us) and measuring latency with rt_task_wait_period(NULL).
But, now rt_task_wait_period() returns immediately.
Then, I reverted back the entire xenomai-3 to my older version. And everything works fine for me.
So, it looks like there is some change happened in latest xenomai-3 repo, which disturbed the rt_task_wait_period API.
Please check, else all my previous efforts will go in vain.
Thanks,
Pintu
Quoted 47 lines · Mauro Salvini
Quoted 17 lines · Philippe Gerum
Quoted 16 lines · Mauro Salvini
Quoted 6 lines · Philippe Gerum
Quoted 5 lines · Mauro Salvini
Hi,
I'm facing an unexpected behavior of
rt_task_wait_period()....
Quoted 1 line
Please try this and let me know if the situation gets any better:
Yes, now it works as expected.
Thank you Philippe.
Quoted 8 lines
Quoted 5 lines
Best regards.
Mauro
Ok, upstreamed. Thanks.
Hi Philippe,
I resume this thread because when I tried your patch I tried only the case that didn't work, that is with
SET_PERIODundefined (sort_task_set_periodic()not called), and didn't re-test also the code withrt_task_set_periodic()call. Sorry, my fault.With this patch applied, when I call
rt_task_set_periodic()(SET_PERIODdefined),rt_task_wait_period()returns-EWOULDBLOCKas ifrt_task_set_periodic()was never called.Thanks in advance, regards
Mauro
_______________________________________________
Xenomai mailing list
[email protected]
https://xenomai.org/mailman/listinfo/xenomai
What version was this working in? I'm assuming you are working out of stable-3.0.x? If you reverted to an older git commit please post the commit.
-Greg
Quoted 79 lines · Pintu Kumar
Oh yes.
I was about to post the similar problem withrt_task_wait_period(NULL).I did "git pull" for my xenomai-3 repo and installed the newer version. After that weird things started happening to my previous test program for latency measurement.
The latency value started giving all wrong results.
In my test programs I was using:rt_task_set_period(100 us)and measuring latency withrt_task_wait_period(NULL).
But, nowrt_task_wait_period()returns immediately.Then, I reverted back the entire xenomai-3 to my older version. And everything works fine for me.
So, it looks like there is some change happened in latest xenomai-3 repo, which disturbed the
rt_task_wait_periodAPI.Please check, else all my previous efforts will go in vain.
Thanks,
PintuQuoted 40 lines · Mauro Salvini
Quoted 17 lines · Philippe Gerum
Quoted 16 lines · Mauro Salvini
Quoted 6 lines · Philippe Gerum
Quoted 5 lines · Mauro Salvini
Hi,
I'm facing an unexpected behavior of
rt_task_wait_period()....
Quoted 1 line
Please try this and let me know if the situation gets any better:
Yes, now it works as expected.
Thank you Philippe.
Quoted 8 lines
Quoted 5 lines
Best regards.
Mauro
Ok, upstreamed. Thanks.
Hi Philippe,
I resume this thread because when I tried your patch I tried only the case that didn't work, that is with
SET_PERIODundefined (sort_task_set_periodic()not called), and didn't re-test also the code withrt_task_set_periodic()call. Sorry, my fault.With this patch applied, when I call
rt_task_set_periodic()(SET_PERIODdefined),rt_task_wait_period()returns-EWOULDBLOCKas ifrt_task_set_periodic()was never called.Thanks in advance, regards
Quoted 7 lines
Mauro
_______________________________________________
Xenomai mailing list
[email protected]
https://xenomai.org/mailman/listinfo/xenomai_______________________________________________
Xenomai mailing list
[email protected]
https://xenomai.org/mailman/listinfo/xenomai
Quoted 4 lines · Greg Gallagher
What version was this working in? I'm assuming you are working out of stable-3.0.x? If you reverted to an older git commit please post the commit.
Sorry, I don't remember the previous working versions. My current xeno-config is:
# xeno-config --info Xenomai version: Xenomai/cobalt v3.0.6 -- #5956064 (2018-03-20 12:13:33 +0100) Linux 4.9.51-x86-64-mine-xeno3-rtdm #1 SMP Mon Apr 9 21:35:39 JST 2018 x86_64 x86_64 x86_64 GNU/Linux Kernel parameters: initrd=0:\initrd.img-4.9.51-x86-64-mine-xeno3-rtdm root=/dev/disk/by-partlabel/system ro ip=off I-pipe release #4 detected Cobalt core 3.0.6 detected Compiler: gcc version 5.4.0 xxx Build args:
With this it is working fine.
However, when I remove everything (/usr/xenomai/) and re-install the latest xenomai-3 (pulled today), it shows problem.
I did not revert any specific commit and tried.
May be I can check that later.
Note: as of now the problem is seen only when using rt_task_wait_period(NULL).
When I use rt_task_sleep() then it works fine.
Thanks,
Pintu
Quoted 82 lines
-Greg
Quoted 79 lines · Pintu Kumar
Oh yes.
I was about to post the similar problem withrt_task_wait_period(NULL).I did "git pull" for my xenomai-3 repo and installed the newer version. After that weird things started happening to my previous test program for latency measurement.
The latency value started giving all wrong results.
In my test programs I was using:rt_task_set_period(100 us)and measuring latency withrt_task_wait_period(NULL).
But, nowrt_task_wait_period()returns immediately.Then, I reverted back the entire xenomai-3 to my older version. And everything works fine for me.
So, it looks like there is some change happened in latest xenomai-3 repo, which disturbed the
rt_task_wait_periodAPI.Please check, else all my previous efforts will go in vain.
Thanks,
PintuQuoted 40 lines · Mauro Salvini
Quoted 17 lines · Philippe Gerum
Quoted 16 lines · Mauro Salvini
Quoted 6 lines · Philippe Gerum
Quoted 5 lines · Mauro Salvini
Hi,
I'm facing an unexpected behavior of
rt_task_wait_period()....
Quoted 1 line
Please try this and let me know if the situation gets any better:
Yes, now it works as expected.
Thank you Philippe.
Quoted 8 lines
Quoted 5 lines
Best regards.
Mauro
Ok, upstreamed. Thanks.
Hi Philippe,
I resume this thread because when I tried your patch I tried only the case that didn't work, that is with
SET_PERIODundefined (sort_task_set_periodic()not called), and didn't re-test also the code withrt_task_set_periodic()call. Sorry, my fault.With this patch applied, when I call
rt_task_set_periodic()(SET_PERIODdefined),rt_task_wait_period()returns-EWOULDBLOCKas ifrt_task_set_periodic()was never called.Thanks in advance, regards
Quoted 7 lines
Mauro
_______________________________________________
Xenomai mailing list
[email protected]
https://xenomai.org/mailman/listinfo/xenomai_______________________________________________
Xenomai mailing list
[email protected]
https://xenomai.org/mailman/listinfo/xenomai
Quoted 26 lines · Pintu Kumar
Quoted 6 lines · Greg Gallagher
What version was this working in? I'm assuming you are working out of
stable-3.0.x? If you reverted to an older git commit please post the
commit.Sorry, I don't remember the previous working versions. My current xeno-config is:
# xeno-config --info Xenomai version: Xenomai/cobalt v3.0.6 -- #5956064 (2018-03-20 12:13:33 +0100) Linux 4.9.51-x86-64-mine-xeno3-rtdm #1 SMP Mon Apr 9 21:35:39 JST 2018 x86_64 x86_64 x86_64 GNU/Linux Kernel parameters: initrd=0:\initrd.img-4.9.51-x86-64-mine-xeno3-rtdm root=/dev/disk/by-partlabel/system ro ip=off I-pipe release #4 detected Cobalt core 3.0.6 detected Compiler: gcc version 5.4.0 xxx Build args:With this it is working fine.
Quoted 7 lines
However, when I remove everything (
/usr/xenomai/) and re-install the latest xenomai-3 (pulled today), it shows problem.
I did not revert any specific commit and tried.
May be I can check that later.
Note: as of now the problem is seen only when usingrt_task_wait_period(NULL).
When I usert_task_sleep()then it works fine.
Hi Greg and Pintu,
commit 73de42cc87f8831694f119359472283f8c7a21e6 on stable branch contains patch that Philippe sent to me some days ago.
He upstreamed it because I told him that patch was working, but in fact as I said in previous mail patch actually corrects one bug (rt_task_wait_period() that not return -EWOULDBLOCK if rt_task_set_periodic() was never called) but exploits another (rt_task_wait_period() return -EWOULDBLOCK also when rt_task_set_periodic() was called).
It is my fault because when Philippe sent me the patch I tested only the previous non-working case and not the working, sorry for the mess.
I'm trying to find where is the bug, but it's not simple because I don't know Xenomai internals.
Thanks, regards
Mauro
No problem, I won't be able to look into it till the weekend so any help debugging is appreciated :)
Quoted 56 lines · Mauro Salvini
Quoted 26 lines · Pintu Kumar
Quoted 6 lines · Greg Gallagher
What version was this working in? I'm assuming you are working out of
stable-3.0.x? If you reverted to an older git commit please post the
commit.Sorry, I don't remember the previous working versions. My current xeno-config is:
# xeno-config --info Xenomai version: Xenomai/cobalt v3.0.6 -- #5956064 (2018-03-20 12:13:33 +0100) Linux 4.9.51-x86-64-mine-xeno3-rtdm #1 SMP Mon Apr 9 21:35:39 JST 2018 x86_64 x86_64 x86_64 GNU/Linux Kernel parameters: initrd=0:\initrd.img-4.9.51-x86-64-mine-xeno3-rtdm root=/dev/disk/by-partlabel/system ro ip=off I-pipe release #4 detected Cobalt core 3.0.6 detected Compiler: gcc version 5.4.0 xxx Build args:With this it is working fine.
Quoted 7 lines
However, when I remove everything (
/usr/xenomai/) and re-install the latest xenomai-3 (pulled today), it shows problem.
I did not revert any specific commit and tried.
May be I can check that later.
Note: as of now the problem is seen only when usingrt_task_wait_period(NULL).
When I usert_task_sleep()then it works fine.Hi Greg and Pintu,
commit
73de42cc87f8831694f119359472283f8c7a21e6on stable branch contains patch that Philippe sent to me some days ago.
He upstreamed it because I told him that patch was working, but in fact as I said in previous mail patch actually corrects one bug (rt_task_wait_period()that not return-EWOULDBLOCKifrt_task_set_periodic()was never called) but exploits another (rt_task_wait_period()return-EWOULDBLOCKalso whenrt_task_set_periodic()was called).It is my fault because when Philippe sent me the patch I tested only the previous non-working case and not the working, sorry for the mess.
I'm trying to find where is the bug, but it's not simple because I don't know Xenomai internals.
Thanks, regards
Mauro
Oh thats great!
Thank you Mauro for your findings :)
So finally I assume that there is some bug introduced with the latest patch. Never mind, until that is fixed (probably by next Monday), I will stick to the previous branch.
Thanks,
Pintu
Quoted 61 lines · Greg Gallagher
No problem, I won't be able to look into it till the weekend so any help debugging is appreciated :)
Quoted 56 lines · Mauro Salvini
Quoted 26 lines · Pintu Kumar
Quoted 6 lines · Greg Gallagher
What version was this working in? I'm assuming you are working out of
stable-3.0.x? If you reverted to an older git commit please post the
commit.Sorry, I don't remember the previous working versions. My current xeno-config is:
# xeno-config --info Xenomai version: Xenomai/cobalt v3.0.6 -- #5956064 (2018-03-20 12:13:33 +0100) Linux 4.9.51-x86-64-mine-xeno3-rtdm #1 SMP Mon Apr 9 21:35:39 JST 2018 x86_64 x86_64 x86_64 GNU/Linux Kernel parameters: initrd=0:\initrd.img-4.9.51-x86-64-mine-xeno3-rtdm root=/dev/disk/by-partlabel/system ro ip=off I-pipe release #4 detected Cobalt core 3.0.6 detected Compiler: gcc version 5.4.0 xxx Build args:With this it is working fine.
Quoted 7 lines
However, when I remove everything (
/usr/xenomai/) and re-install the latest xenomai-3 (pulled today), it shows problem.
I did not revert any specific commit and tried.
May be I can check that later.
Note: as of now the problem is seen only when usingrt_task_wait_period(NULL).
When I usert_task_sleep()then it works fine.Hi Greg and Pintu,
commit
73de42cc87f8831694f119359472283f8c7a21e6on stable branch contains patch that Philippe sent to me some days ago.
He upstreamed it because I told him that patch was working, but in fact as I said in previous mail patch actually corrects one bug (rt_task_wait_period()that not return-EWOULDBLOCKifrt_task_set_periodic()was never called) but exploits another (rt_task_wait_period()return-EWOULDBLOCKalso whenrt_task_set_periodic()was called).It is my fault because when Philippe sent me the patch I tested only the previous non-working case and not the working, sorry for the mess.
I'm trying to find where is the bug, but it's not simple because I don't know Xenomai internals.
Thanks, regards
Mauro
Quoted 2 lines · Greg Gallagher
No problem, I won't be able to look into it till the weekend so any help debugging is appreciated :)
Brown paper bag bug. The change was tested on Mercury only, where timer ids cannot be zero; zero is a perfectly valid timer id with Cobalt. Oh, well. I'll send a fix tested on both ends.
Quoted 65 lines
Quoted 49 lines · Mauro Salvini
Quoted 26 lines · Pintu Kumar
Quoted 6 lines · Greg Gallagher
What version was this working in? I'm assuming you are working out of
stable-3.0.x? If you reverted to an older git commit please post the
commit.Sorry, I don't remember the previous working versions. My current xeno-config is:
# xeno-config --info Xenomai version: Xenomai/cobalt v3.0.6 -- #5956064 (2018-03-20 12:13:33 +0100) Linux 4.9.51-x86-64-mine-xeno3-rtdm #1 SMP Mon Apr 9 21:35:39 JST 2018 x86_64 x86_64 x86_64 GNU/Linux Kernel parameters: initrd=0:\initrd.img-4.9.51-x86-64-mine-xeno3-rtdm root=/dev/disk/by-partlabel/system ro ip=off I-pipe release #4 detected Cobalt core 3.0.6 detected Compiler: gcc version 5.4.0 xxx Build args:With this it is working fine.
Quoted 7 lines
However, when I remove everything (
/usr/xenomai/) and re-install the latest xenomai-3 (pulled today), it shows problem.
I did not revert any specific commit and tried.
May be I can check that later.
Note: as of now the problem is seen only when usingrt_task_wait_period(NULL).
When I usert_task_sleep()then it works fine.Hi Greg and Pintu,
commit
73de42cc87f8831694f119359472283f8c7a21e6on stable branch contains patch that Philippe sent to me some days ago.
He upstreamed it because I told him that patch was working, but in fact as I said in previous mail patch actually corrects one bug (rt_task_wait_period()that not return-EWOULDBLOCKifrt_task_set_periodic()was never called) but exploits another (rt_task_wait_period()return-EWOULDBLOCKalso whenrt_task_set_periodic()was called).It is my fault because when Philippe sent me the patch I tested only the previous non-working case and not the working, sorry for the mess.
Quoted 7 lines
I'm trying to find where is the bug, but it's not simple because I don't know Xenomai internals.
Thanks, regards
Mauro
_______________________________________________
Xenomai mailing list
[email protected]
https://xenomai.org/mailman/listinfo/xenomai
Signature · 1 line
Philippe.