All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexandre Coffignal <alexandre.coffignal@domain.hid>
To: xenomai@xenomai.org
Subject: [Xenomai-help] How to fix t_delete call in psos skin?
Date: Wed, 04 Nov 2009 10:20:12 +0100	[thread overview]
Message-ID: <4AF1474C.7000701@domain.hid> (raw)

[-- 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 */
 

             reply	other threads:[~2009-11-04  9:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-04  9:20 Alexandre Coffignal [this message]
2009-11-04 10:50 ` [Xenomai-core] [Xenomai-help] How to fix t_delete call in psos skin? Philippe Gerum
2009-11-05 10:54   ` Alexandre Coffignal
2009-11-06 11:28     ` Philippe Gerum

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4AF1474C.7000701@domain.hid \
    --to=alexandre.coffignal@domain.hid \
    --cc=xenomai@xenomai.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.