Module: xenomai-2.4
Branch: master
Commit: a473a11f6d717b7bd098ce8cbc0ef6e329dbffb5
URL:    
http://git.xenomai.org/?p=xenomai-2.4.git;a=commit;h=a473a11f6d717b7bd098ce8cbc0ef6e329dbffb5

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   |    4 ++++
 ksrc/nucleus/pod.c         |   12 ++++++++++++
 ksrc/nucleus/thread.c      |    3 +++
 ksrc/skins/posix/syscall.c |    4 ++--
 ksrc/skins/posix/thread.c  |    7 -------
 ksrc/skins/posix/thread.h  |    4 ----
 6 files changed, 21 insertions(+), 13 deletions(-)

diff --git a/include/nucleus/thread.h b/include/nucleus/thread.h
index 3eefb53..b651bd8 100644
--- a/include/nucleus/thread.h
+++ b/include/nucleus/thread.h
@@ -142,6 +142,7 @@ struct xnthread;
 struct xnsched;
 struct xnsynch;
 struct xnrpi;
+struct xnselector;
 
 typedef struct xnthrops {
 
@@ -207,6 +208,9 @@ typedef struct xnthread {
        xnstat_exectime_t account; /* Execution time accounting entity */
        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 */
 
diff --git a/ksrc/nucleus/pod.c b/ksrc/nucleus/pod.c
index 9348ce1..bee6a04 100644
--- a/ksrc/nucleus/pod.c
+++ b/ksrc/nucleus/pod.c
@@ -41,6 +41,7 @@
 #include <nucleus/registry.h>
 #include <nucleus/module.h>
 #include <nucleus/stat.h>
+#include <nucleus/select.h>
 #include <asm/xenomai/bits/pod.h>
 
 /* debug support */
@@ -1204,6 +1205,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);
 
@@ -1283,6 +1293,8 @@ void xnpod_abort_thread(xnthread_t *thread)
        if (!xnpod_current_p(thread))
                xnpod_suspend_thread(thread, XNDORMANT, XN_INFINITE, 
XN_RELATIVE, NULL);
        xnpod_delete_thread(thread);
+       /* FIXME: in case thread has a selector, the xnfree(selector)
+          happens with nklock locked. */
        xnlock_put_irqrestore(&nklock, s);
 }
 
diff --git a/ksrc/nucleus/thread.c b/ksrc/nucleus/thread.c
index 5fceaec..0969c90 100644
--- a/ksrc/nucleus/thread.c
+++ b/ksrc/nucleus/thread.c
@@ -123,6 +123,9 @@ int xnthread_init(xnthread_t *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);
 
        xnarch_init_display_context(thread);
diff --git a/ksrc/skins/posix/syscall.c b/ksrc/skins/posix/syscall.c
index f8c79d9..6427d40 100644
--- a/ksrc/skins/posix/syscall.c
+++ b/ksrc/skins/posix/syscall.c
@@ -2370,11 +2370,11 @@ static int __select(struct task_struct *curr, 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 ad4aaa5..6e89625 100644
--- a/ksrc/skins/posix/thread.c
+++ b/ksrc/skins/posix/thread.c
@@ -78,12 +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);
-               thread->selector = NULL;
-       }
-#endif /* CONFIG_XENO_OPT_POSIX_SELECT */
 
        switch (thread_getdetachstate(thread)) {
        case PTHREAD_CREATE_DETACHED:
@@ -216,7 +210,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) {
                xnthread_time_slice(&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