Module: xenomai-gch
Branch: for-head
Commit: 0bf1de88dad5e27dffdbafdc3ecfc02a4673a911
URL:    
http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=0bf1de88dad5e27dffdbafdc3ecfc02a4673a911

Author: Peter Soetens <pe...@thesourceworks.com>
Date:   Thu Oct  1 15:57:54 2009 +0200

nucleus: move posix selector in nucleus for every skin to use.

This patch makes the select implementation in syscall.c independent of the
posix skin.

---

 include/nucleus/thread.h   |    5 +++++
 ksrc/nucleus/pod.c         |   12 ++++++++++++
 ksrc/nucleus/thread.c      |    3 +++
 ksrc/skins/posix/syscall.c |    4 ++--
 ksrc/skins/posix/thread.c  |   16 ----------------
 ksrc/skins/posix/thread.h  |    4 ----
 6 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/include/nucleus/thread.h b/include/nucleus/thread.h
index bcd5858..389a12b 100644
--- a/include/nucleus/thread.h
+++ b/include/nucleus/thread.h
@@ -168,6 +168,7 @@ typedef struct xnthread_info {
 struct xnthread;
 struct xnsynch;
 struct xnsched;
+struct xnselector;
 struct xnsched_class;
 struct xnsched_tpslot;
 union xnsched_policy_param;
@@ -287,6 +288,10 @@ typedef struct xnthread {
                xnstat_exectime_t lastperiod; /* Interval marker for execution 
time reports */
        } stat;
 
+#ifdef CONFIG_XENO_OPT_SELECT
+       struct xnselector *selector;    /* For select. */
+#endif /* CONFIG_XENO_OPT_SELECT */
+
        int errcode;                    /* Local errno */
 
        xnasr_t asr;                    /* Asynchronous service routine */
diff --git a/ksrc/nucleus/pod.c b/ksrc/nucleus/pod.c
index 370ad28..77c69fd 100644
--- a/ksrc/nucleus/pod.c
+++ b/ksrc/nucleus/pod.c
@@ -43,6 +43,7 @@
 #include <nucleus/module.h>
 #include <nucleus/stat.h>
 #include <nucleus/assert.h>
+#include <nucleus/select.h>
 #include <asm/xenomai/bits/pod.h>
 
 #ifndef CONFIG_XENO_OPT_DEBUG_NUCLEUS
@@ -1186,6 +1187,15 @@ void xnpod_delete_thread(xnthread_t *thread)
        xntimer_destroy(&thread->rtimer);
        xntimer_destroy(&thread->ptimer);
 
+#ifdef CONFIG_XENO_OPT_SELECT
+       if (thread->selector) {
+               xnselector_destroy(thread->selector);
+               xnheap_schedule_free(&kheap, thread->selector, 
+                                    (xnholder_t *)thread->selector);
+               thread->selector = NULL;
+       }
+#endif /* CONFIG_XENO_OPT_SELECT */
+
        if (xnthread_test_state(thread, XNPEND))
                xnsynch_forget_sleeper(thread);
 
@@ -1274,6 +1284,8 @@ void xnpod_abort_thread(xnthread_t *thread)
                                     XN_INFINITE, XN_RELATIVE, NULL);
        xnthread_set_info(thread, XNABORT);
        xnpod_delete_thread(thread);
+       /* FIXME: in case thread has a selector, the xnfree(selector)
+          happens with nklock locked. */
        xnlock_put_irqrestore(&nklock, s);
 }
 EXPORT_SYMBOL_GPL(xnpod_abort_thread);
diff --git a/ksrc/nucleus/thread.c b/ksrc/nucleus/thread.c
index 7f09ba9..8e55fca 100644
--- a/ksrc/nucleus/thread.c
+++ b/ksrc/nucleus/thread.c
@@ -140,6 +140,9 @@ int xnthread_init(struct xnthread *thread,
        initph(&thread->xlink);
        thread->rpi = NULL;
 #endif /* CONFIG_XENO_OPT_PRIOCPL */
+#ifdef CONFIG_XENO_OPT_SELECT
+       thread->selector = NULL;
+#endif /* CONFIG_XENO_OPT_SELECT */
        initpq(&thread->claimq);
 
        thread->sched = sched;
diff --git a/ksrc/skins/posix/syscall.c b/ksrc/skins/posix/syscall.c
index 898cc91..8c18e37 100644
--- a/ksrc/skins/posix/syscall.c
+++ b/ksrc/skins/posix/syscall.c
@@ -2343,11 +2343,11 @@ static int __select(struct pt_regs *regs)
        xntmode_t mode = XN_RELATIVE;
        struct xnselector *selector;
        struct timeval tv;
-       pthread_t thread;
+       xnthread_t *thread;
        int i, err, nfds;
        size_t fds_size;
 
-       thread = pse51_current_thread();
+       thread = xnpod_current_thread();
        if (!thread)
                return -EPERM;
 
diff --git a/ksrc/skins/posix/thread.c b/ksrc/skins/posix/thread.c
index 9b93a53..87ff38c 100644
--- a/ksrc/skins/posix/thread.c
+++ b/ksrc/skins/posix/thread.c
@@ -66,9 +66,6 @@ static void thread_trampoline(void *cookie)
 static void thread_delete_hook(xnthread_t *xnthread)
 {
        pthread_t thread = thread2pthread(xnthread);
-#ifdef CONFIG_XENO_OPT_POSIX_SELECT
-       struct xnselector *selector = NULL;
-#endif /* CONFIG_XENO_OPT_POSIX_SELECT */
        spl_t s;
 
        if (!thread)
@@ -81,13 +78,6 @@ static void thread_delete_hook(xnthread_t *xnthread)
        pse51_mark_deleted(thread);
        pse51_signal_cleanup_thread(thread);
        pse51_timer_cleanup_thread(thread);
-#ifdef CONFIG_XENO_OPT_POSIX_SELECT
-       if (thread->selector) {
-               xnselector_destroy(thread->selector);
-               selector = thread->selector;
-               thread->selector = NULL;
-       }
-#endif /* CONFIG_XENO_OPT_POSIX_SELECT */
 
        switch (thread_getdetachstate(thread)) {
        case PTHREAD_CREATE_DETACHED:
@@ -109,11 +99,6 @@ static void thread_delete_hook(xnthread_t *xnthread)
        }
 
        xnlock_put_irqrestore(&nklock, s);
-
-#ifdef CONFIG_XENO_OPT_POSIX_SELECT
-       if (selector)
-               xnfree(selector);
-#endif /* CONFIG_XENO_OPT_POSIX_SELECT */
 }
 
 /**
@@ -254,7 +239,6 @@ int pthread_create(pthread_t *tid,
        pse51_signal_init_thread(thread, cur);
        pse51_tsd_init_thread(thread);
        pse51_timer_init_thread(thread);
-       thread->selector = NULL;
 
        if (thread->attr.policy == SCHED_RR)
                xnpod_set_thread_tslice(&thread->threadbase, pse51_time_slice);
diff --git a/ksrc/skins/posix/thread.h b/ksrc/skins/posix/thread.h
index 33b14fd..fc8c6fe 100644
--- a/ksrc/skins/posix/thread.h
+++ b/ksrc/skins/posix/thread.h
@@ -21,7 +21,6 @@
 #define _POSIX_THREAD_H
 
 #include <posix/internal.h>
-#include <nucleus/select.h>
 
 typedef unsigned long long pse51_sigset_t;
 
@@ -91,9 +90,6 @@ struct pse51_thread {
     /* For timers. */
     xnqueue_t timersq;
     
-    /* For select. */
-    struct xnselector *selector;
-
 #ifdef CONFIG_XENO_OPT_PERVASIVE
     struct pse51_hkey hkey;
 #endif /* CONFIG_XENO_OPT_PERVASIVE */


_______________________________________________
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git

Reply via email to