Jan Kiszka wrote:
Philippe Gerum wrote:
Jan Kiszka wrote:
Hi Philippe,
please have a look at skins/rtai/syscall.c:
static xnsysent_t __systab[] = {
...
[__rtai_task_delete ] = { &__rt_task_delete, __xn_exec_primary },
^^^^^^^^^^^^^^^^^
Is this restriction to shadow threads unavoidable? I was trying to
kill a task from main(), while main() was not converted into a fusion
thread.
I think the reason is that, to commit suicide, a fusion thread has to
be switched back to primary mode. But then, how to explicitly kill a
task from Linux context? The succeeding pthread_cancel in lib/task.c
does not have any effect, only the process termination finally cleans
up. That was too late in my case - the task went wild before due to
other resource cleanups. One may avoid such scenarios, but it makes
the usage of rt_task_delete unintuitive.
What about this: use __xn_exec_any, but switch back in
__rt_task_delete if self-deletion is detected (task == self).
As you noticed, the primary mode is only requested for threads
committing suicide, but not for others. I think that using the
__xn_exec_conforming mode for this syscall would do it.
Aah, yet another syscall flag! Sorry, to forget about this one. ;)
Ah! but this time, this has been documented! :o)
include/asm-generic/syscall.h:
/* Syscall must run into the Linux domain. */
#define __xn_exec_lostage 0x1
/* Syscall must run into the RTAI domain. */
#define __xn_exec_histage 0x2
/* Shadow syscall; caller must be mapped. */
#define __xn_exec_shadow 0x4
/* Switch back toggle; caller must return to its original mode. */
#define __xn_exec_switchback 0x8
/* Exec in current domain. */
#define __xn_exec_current 0x10
/* Exec in conforming domain, RTAI for fusion threads, Linux otherwise. */
#define __xn_exec_conforming 0x20
/* Context-agnostic syscall. */
#define __xn_exec_any 0x0
/* Short-hand for shadow init syscall. */
#define __xn_exec_init __xn_exec_lostage
/* Short-hand for shadow syscall in RTAI space. */
#define __xn_exec_primary (__xn_exec_shadow|__xn_exec_histage)
/* Short-hand for shadow syscall in Linux space. */
#define __xn_exec_secondary (__xn_exec_shadow|__xn_exec_lostage)
Indeed, this works very well. Please apply to cvs.
Ok.
Thanks,
Jan
--
Philippe.