Module: xenomai-forge
Branch: next
Commit: ef45a51cbac5f7e5b0704b73d6140d1abea79c76
URL:    
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=ef45a51cbac5f7e5b0704b73d6140d1abea79c76

Author: Philippe Gerum <r...@xenomai.org>
Date:   Mon Mar  3 18:06:01 2014 +0100

cobalt/shadow: propagate CPU migration event to personalities

This patch extends the personality operations, with the .move_thread()
event handler, which is called when the regular kernel decides to move
a thread to another CPU.

The handler is called nklock held, IRQs off. The Cobalt TCB of the
affected thread is not updated yet, when the call is made.

---

 include/cobalt/kernel/shadow.h |    2 ++
 include/cobalt/kernel/thread.h |    4 ++--
 kernel/cobalt/shadow.c         |    1 +
 3 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/include/cobalt/kernel/shadow.h b/include/cobalt/kernel/shadow.h
index 0b18aa0..81165bd 100644
--- a/include/cobalt/kernel/shadow.h
+++ b/include/cobalt/kernel/shadow.h
@@ -45,6 +45,8 @@ struct xnpersonality {
                struct xnpersonality *(*map_thread)(struct xnthread *thread);
                struct xnpersonality *(*relax_thread)(struct xnthread *thread);
                struct xnpersonality *(*harden_thread)(struct xnthread *thread);
+               struct xnpersonality *(*move_thread)(struct xnthread *thread,
+                                                    int dest_cpu);
                struct xnpersonality *(*exit_thread)(struct xnthread *thread);
                struct xnpersonality *(*finalize_thread)(struct xnthread 
*thread);
        } ops;
diff --git a/include/cobalt/kernel/thread.h b/include/cobalt/kernel/thread.h
index 387b6f4..317c4cc 100644
--- a/include/cobalt/kernel/thread.h
+++ b/include/cobalt/kernel/thread.h
@@ -246,13 +246,13 @@ static inline struct xnarchtcb *xnthread_archtcb(struct 
xnthread *thread)
 #define xnthread_for_each_claimed_safe(__pos, __tmp, __thread) \
        list_for_each_entry_safe(__pos, __tmp, &(__thread)->claimq, link)
 
-#define xnthread_run_handler(__t, __h)                                 \
+#define xnthread_run_handler(__t, __h, __a...)                         \
        do {                                                            \
                struct xnpersonality *__p__ = (__t)->personality;       \
                do {                                                    \
                        if ((__p__)->ops.__h == NULL)                   \
                                break;                                  \
-                       __p__ = (__p__)->ops.__h(__t);                  \
+                       __p__ = (__p__)->ops.__h(__t, ##__a);           \
                } while (__p__);                                        \
        } while (0)
        
diff --git a/kernel/cobalt/shadow.c b/kernel/cobalt/shadow.c
index 0d045dc..e3ef15f 100644
--- a/kernel/cobalt/shadow.c
+++ b/kernel/cobalt/shadow.c
@@ -343,6 +343,7 @@ static int handle_setaffinity_event(struct 
ipipe_cpu_migration_data *d)
         */
        xnlock_get_irqsave(&nklock, s);
        cpus_and(thread->affinity, p->cpus_allowed, nkaffinity);
+       xnthread_run_handler(thread, move_thread, d->dest_cpu);
        xnlock_put_irqrestore(&nklock, s);
 
        /*


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai-git

Reply via email to