All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai-help] How to fix t_delete call in psos skin?
@ 2009-11-04  9:20 Alexandre Coffignal
  2009-11-04 10:50 ` [Xenomai-core] " Philippe Gerum
  0 siblings, 1 reply; 4+ messages in thread
From: Alexandre Coffignal @ 2009-11-04  9:20 UTC (permalink / raw)
  To: xenomai

[-- Attachment #1: Type: text/plain, Size: 3188 bytes --]

Hello,

I'm trying to use t_delete routine in psos skin (xenomai-2.4.7) from a 
user space application .
I'm encountring two different behaviors:
-1- Calling t_delete(0) from a psos task seems to work perfectly (e.g. 
task self deletes).
-2- Calling t_delete(task_id) with another task id (e.g. current task 
tries to delete another task) doesn't result in task deletion but 
returns 0 (success).

I've been through both psos skin (ksrc/psos+/task.c) and nucleus 
(ksrc/nucleus/pod.c) source code.

xnpod_delete_thread() behaves differently depending on previously 
described t_delete calls:

-1- First case (t_delete(0)):

Execution skip condition in ksrc/nucleus/pod.c at line 1173:

  if (xnthread_user_task(thread) != NULL &&
      !xnthread_test_state(thread, XNDORMANT) &&
      !xnpod_current_p(thread)) {
      if (!xnpod_userspace_p())
          xnshadow_send_sig(thread, SIGKILL, 1);
      /*
       * Otherwise, assume the interface library has issued
       * pthread_cancel on the target thread, which should
       * cause the current service to be called for
       * self-deletion of that thread.
       */
      goto unlock_and_exit;
  }
#endif /* CONFIG_XENO_OPT_PERVASIVE */

and continues to run after it. This results in a successful deletion.


-2- Second case:

Execution enters one of the first conditions (if 
(xnthread_user_task(thread))...)  but skip the second one : 
xnshadow_send_sig(thread, SIGKILL, 1) is not executed;
goto unlock_and_exit; instruction is then executed.
->Our thread is never deleted.

-3-
Modifing actual source code by commenting goto intruction or moving it 
into second condition (if (!xnpod_userspace_p()) mentioned above) 
results in a working t_delete (task_id).

- I'm not sure of the possible side effects of such a modification?
- Is it correct to do so?


As mentioned in the source code comment, it is assumed "the interface 
library has issued pthread_cancel" ...
I assume it might be missing somewhere?

Please can you help on this topic?

Thanks in advance.

Please find a patch regarding this modification.

diff --git a/ksrc/nucleus/pod.c b/ksrc/nucleus/pod.c
index 9348ce1..ee362df 100644
--- a/ksrc/nucleus/pod.c
+++ b/ksrc/nucleus/pod.c
@@ -1177,14 +1177,16 @@ void xnpod_delete_thread(xnthread_t *thread)
            !xnthread_test_state(thread, XNDORMANT) &&
            !xnpod_current_p(thread)) {
                if (!xnpod_userspace_p())
+               {
                        xnshadow_send_sig(thread, SIGKILL, 1);
+                       goto unlock_and_exit;
+               }
                /*
                 * Otherwise, assume the interface library has issued
                 * pthread_cancel on the target thread, which should
                 * cause the current service to be called for
                 * self-deletion of that thread.
                 */
-               goto unlock_and_exit;
        }
 #endif /* CONFIG_XENO_OPT_PERVASIVE */
 


Fabrice.


--------------------------------
CénoSYS <http://www.cenosys.com>
10, Rue Xavier Bichat
F-72000 Le MANS
--------------------------------



[-- Attachment #2: pod.patch --]
[-- Type: text/x-patch, Size: 675 bytes --]

diff --git a/ksrc/nucleus/pod.c b/ksrc/nucleus/pod.c
index 9348ce1..ee362df 100644
--- a/ksrc/nucleus/pod.c
+++ b/ksrc/nucleus/pod.c
@@ -1177,14 +1177,16 @@ void xnpod_delete_thread(xnthread_t *thread)
 	    !xnthread_test_state(thread, XNDORMANT) &&
 	    !xnpod_current_p(thread)) {
 		if (!xnpod_userspace_p())
+		{
 			xnshadow_send_sig(thread, SIGKILL, 1);
+			goto unlock_and_exit;
+		}
 		/*
 		 * Otherwise, assume the interface library has issued
 		 * pthread_cancel on the target thread, which should
 		 * cause the current service to be called for
 		 * self-deletion of that thread.
 		 */
-		goto unlock_and_exit;
 	}
 #endif /* CONFIG_XENO_OPT_PERVASIVE */
 

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-11-06 11:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-04  9:20 [Xenomai-help] How to fix t_delete call in psos skin? Alexandre Coffignal
2009-11-04 10:50 ` [Xenomai-core] " Philippe Gerum
2009-11-05 10:54   ` Alexandre Coffignal
2009-11-06 11:28     ` Philippe Gerum

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.