rtdm_event_timedwait returns -EINTR
Quoted 3 lines
Assuming you are using the native API (the POSIX interface would have to be adapted the same way), does the following patch help?
The patch doesn't make any difference. It could be because I use mostly rtdm skin in the driver, not native. And the native skin example already resets syscall (but with wrong timeout).
Meanwhile I have found out the type of the signal, which interrupts my syscalls. It's SIGWINCH (or perhaps SIGHARDEN). What is exactly this signal used for, should it be interrupting syscalls?
Petr
Quoted 7 lines · Petr Cervenka
Quoted 3 lines
Assuming you are using the native API (the POSIX interface would have to be adapted the same way), does the following patch help?
The patch doesn't make any difference. It could be because I use mostly rtdm skin in the driver, not native. And the native skin example already resets syscall (but with wrong timeout).
Meanwhile I have found out the type of the signal, which interrupts my syscalls. It's SIGWINCH (or perhaps SIGHARDEN). What is exactly this signal used for, should it be interrupting syscalls?
This is a signal internally used by skins to force a thread in primary mode; it should not do interrupt syscalls, provided we set the sigaction flags properly.
Quoted 3 lines
Petr
Signature · 1 line
Philippe.
Quoted 5 lines · Philippe Gerum
Quoted 4 lines · Petr Cervenka
Quoted 3 lines
Assuming you are using the native API (the POSIX interface would have to be adapted the same way), does the following patch help?
Quoted 8 lines
Quoted 3 lines
The patch doesn't make any difference. It could be because I use mostly rtdm skin in the driver, not native. And the native skin example already resets syscall (but with wrong timeout).
Meanwhile I have found out the type of the signal, which interrupts my syscalls. It's SIGWINCH (or perhaps SIGHARDEN). What is exactly this signal used for, should it be interrupting syscalls?
This is a signal internally used by skins to force a thread in primary mode; it should not do interrupt syscalls, provided we set the sigaction flags properly.
Read: it must interrupt Xenomai syscalls internally but the latter should always be silently restarted, by properly setting the SA_RESTART bit in the sigaction flags for that signal.
Not allowing Linux to interrupt blocking Xenomai syscalls to process pending signals would basically kill GDB support, and beyond this create a very fragile situation wrt signal handling and Xenomai, which is the last thing we would want to do.
Quoted 3 lines
Quoted 3 lines
Petr
Signature · 1 line
Philippe.
Quoted 5 lines
Read: it must interrupt Xenomai syscalls internally but the latter should always be silently restarted, by properly setting the
SA_RESTARTbit in the sigaction flags for that signal.
Quoted 7 lines
Not allowing Linux to interrupt blocking Xenomai syscalls to process pending signals would basically kill GDB support, and beyond this create a very fragile situation wrt signal handling and Xenomai, which is the last thing we would want to do.
Philippe.
I have found following problems / errors:
--------------------------------------------------------------
1) rtdm_event_timedwait() in ioctl handler is not automatically internally restarted (driver: rtdm, app. tasks: native)
2) computer hangs, when I call in ioctl handler something like:
do {
res = rtdm_event_timedwait(&event, timeout, NULL);
} while (res == -EINTR);
this could have perhaps some relevance: https://mail.gna.org/public/xenomai-help/2008-11/msg00025.html
3) rt_event_wait() in application is restarted always with the same relative timeout. it could run forever.
problems with version 2.5-rc1:
-----------------------------------------------
1) function rt_task_shadow always returns -EFAULT
2) when resizing window with latency test running, it prints out "Not SIGSHADOW !". But it should be SIGSHADOW (in my opinion).
Petr
Quoted 9 lines · Petr Cervenka
Quoted 9 lines
Read: it must interrupt Xenomai syscalls internally but the latter should always be silently restarted, by properly setting the
SA_RESTARTbit in the sigaction flags for that signal.Not allowing Linux to interrupt blocking Xenomai syscalls to process pending signals would basically kill GDB support, and beyond this create a very fragile situation wrt signal handling and Xenomai, which is the last thing we would want to do.
Quoted 7 lines
Quoted 2 lines
Philippe.
I have found following problems / errors:
-------------------------------------------------------------- 1)rtdm_event_timedwait()in ioctl handler is not automatically internally restarted (driver: rtdm, app. tasks: native)
That is because rtdm_event_timedwait is not a syscall. It is a kernel-space call. Your job is to get ioctl to return -EINTR when rtdm_event_timedwait returns -EINTR, so that ioctl will be restarted in user-space.
This is undocumented, because you should already know about that if you have done a little driver work under linux.
Quoted 5 lines
2) computer hangs, when I call in ioctl handler something like: do { res =
rtdm_event_timedwait(&event, timeout, NULL); } while (res ==-EINTR); this could have perhaps some relevance:
https://mail.gna.org/public/xenomai-help/2008-11/msg00025.html
That is because you should return to user-space to get the signal handled.
Quoted 3 lines
3)
rt_event_wait()in application is restarted always with the same relative timeout. it could run forever.
Yes, we know that, and we know a fix. But another fix is to use the new *_until calls.
Quoted 4 lines
problems with version 2.5-rc1:
----------------------------------------------- 1) functionrt_task_shadowalways returns-EFAULT
Could you provide us with a small example which has this problem ?
Quoted 3 lines
2) when resizing window with latency test running, it prints out "Not SIGSHADOW !". But it should be SIGSHADOW (in my opinion).
"Not SIGSHADOW!" is printed when the SIGWINCH signal handler identifies a SIGWINCH not originating from Xenomai. And when you resize the window, a SIGWINCH is sent to the application which originates from the Linux kernel, not from Xenomai. So, the "Not SIGSHADOW!" is correct. However, it is essentially a debug message
Quoted 6 lines
Petr
_______________________________________________ Xenomai-help mailing list [email protected] https://mail.gna.org/listinfo/xenomai-help
Signature · 1 line
Gilles.
Quoted 17 lines · Petr Cervenka
Quoted 5 lines
Read: it must interrupt Xenomai syscalls internally but the latter should always be silently restarted, by properly setting the
SA_RESTARTbit in the sigaction flags for that signal.Quoted 7 lines
Not allowing Linux to interrupt blocking Xenomai syscalls to process pending signals would basically kill GDB support, and beyond this create a very fragile situation wrt signal handling and Xenomai, which is the last thing we would want to do.
Philippe.
I have found following problems / errors:
--------------------------------------------------------------
1)rtdm_event_timedwait()in ioctl handler is not automatically internally restarted (driver: rtdm, app. tasks: native)
Quoted 6 lines
2) computer hangs, when I call in ioctl handler something like:
do {
res =rtdm_event_timedwait(&event, timeout, NULL);
} while (res ==-EINTR);From any kernel space API called from userland syscalls:
res = whatever_xenomai_skin_blocking_call(...); if (res == -EINTR)
return -EINTR;
Quoted 4 lines
this could have perhaps some relevance: https://mail.gna.org/public/xenomai-help/2008-11/msg00025.html
3)
rt_event_wait()in application is restarted always with the same relative timeout. it could run forever.
As discussed earlier, using rt_event_wait_until() with an absolute timeout spec would fix this (2.5 only though).
Quoted 4 lines
problems with version 2.5-rc1:
-----------------------------------------------
1) functionrt_task_shadowalways returns-EFAULT
Are you passing a NULL task pointer?
Quoted 4 lines
2) when resizing window with latency test running, it prints out "Not SIGSHADOW !". But it should be SIGSHADOW (in my opinion).
Petr
Signature · 1 line
Philippe.
From: [email protected]
Quoted 7 lines
Quoted 4 lines · Petr Cervenka
I have found following problems / errors:
-------------------------------------------------------------- 1)rtdm_event_timedwait()in ioctl handler is not automatically internally restarted (driver: rtdm, app. tasks: native)
Quoted 8 lines
That is because
rtdm_event_timedwaitis not a syscall. It is a kernel-space call. Your job is to get ioctl to return-EINTRwhenrtdm_event_timedwaitreturns-EINTR, so that ioctl will be restarted in user-space.This is undocumented, because you should already know about that if you have done a little driver work under linux.
Finally I start to understand it. Sorry, but I wrote only couple of drivers. With knowledge of hardware but not linux.
Quoted 8 lines
Quoted 5 lines
2) computer hangs, when I call in ioctl handler something like: do { res =
rtdm_event_timedwait(&event, timeout, NULL); } while (res ==-EINTR); this could have perhaps some relevance:
https://mail.gna.org/public/xenomai-help/2008-11/msg00025.htmlThat is because you should return to user-space to get the signal handled.
So it is better to divide longer operation with device (for example initialization) into two ioctls. First one for registry settings and second one for waiting for ready state. Or am I wrong?
Quoted 8 lines
Quoted 3 lines
3)
rt_event_wait()in application is restarted always with the same relative timeout. it could run forever.Yes, we know that, and we know a fix. But another fix is to use the new
*_untilcalls.Quoted 1 line
Quoted 6 lines
Quoted 3 lines
problems with version 2.5-rc1:
----------------------------------------------- 1) functionrt_task_shadowalways returns-EFAULTCould you provide us with a small example which has this problem ?
Example is in the attachment.
Quoted 10 lines
Quoted 3 lines
2) when resizing window with latency test running, it prints out "Not SIGSHADOW !". But it should be SIGSHADOW (in my opinion).
"Not SIGSHADOW!" is printed when the SIGWINCH signal handler identifies a SIGWINCH not originating from Xenomai. And when you resize the window, a SIGWINCH is sent to the application which originates from the Linux kernel, not from Xenomai. So, the "Not SIGSHADOW!" is correct. However, it is essentially a debug message
Oh, it my fault. When I identified these signals as SIGWINCH, I automatically assumed that it's SIGHARDEN. I completely forgot to look at the basic mean of SIGWINCH signal. I feel little ashamed.
Petr
#include <sys/mman.h>
#include <native/task.h>
#include <native/event.h>
#include <native/timer.h>
#define MY_EVENT 0x00000001ll
#define MY_PRIORITY 99
static RT_TASK mainTask;
int main(int argc, char** argv) {
const double ONE_SEC = 1e9;
const RTIME timeout = (RTIME)(5 * ONE_SEC);
RT_EVENT event;
unsigned long mask;
RTIME start, end;
int res;
mlockall(MCL_CURRENT | MCL_FUTURE);
res = rt_task_shadow(&mainTask, "main_task", MY_PRIORITY, 0);
if (res < 0) {
printf("rt_task_shadow(): %d (%s)\n", res, strerror(-res));
}
res = rt_task_set_mode(0, T_PRIMARY, NULL);
if (res < 0) {
printf("rt_task_set_mode(): %d (%s)\n", res, strerror(-res));
}
res = rt_event_create(&event, NULL, 0, EV_PRIO);
if (res < 0) {
printf("rt_event_create(): %d (%s)\n", res, strerror(-res));
}
start = rt_timer_read();
res = rt_event_wait(&event, MY_EVENT, &mask, EV_ALL, rt_timer_ns2ticks(timeout));
end = rt_timer_read();
if (res < 0 && res != -ETIMEDOUT) {
printf("rt_event_wait(): %d (%s)\n", res, strerror(-res));
}
printf("time - measured %g s, wanted %g s\n", rt_timer_ticks2ns(end - start)/ONE_SEC, timeout/ONE_SEC);
res = rt_event_delete(&event);
if (res < 0) {
printf("rt_event_delete(): %d (%s)\n", res, strerror(-res));
}
return 0;
}