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

Author: Philippe Gerum <r...@xenomai.org>
Date:   Wed Sep 25 10:25:44 2013 +0200

cobalt/posix/thread: introduce ->thread_setsched() extension handler

We need a way to inform extensions about a policy change to happen
soon for a thread.

The new ->thread_setsched() handler is called with interrupts off,
nklocked held, right before the change takes place. The handler is
passed the new scheduling class and parameters which will be applied
upon return.

The handler is guaranteed that the change will take place upon return
(no error path behind the extension call).

---

 kernel/cobalt/posix/extension.h |    5 +++++
 kernel/cobalt/posix/thread.c    |    8 +++++++-
 2 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/kernel/cobalt/posix/extension.h b/kernel/cobalt/posix/extension.h
index 5c39c01..78cfc6f 100644
--- a/kernel/cobalt/posix/extension.h
+++ b/kernel/cobalt/posix/extension.h
@@ -29,6 +29,8 @@ struct cobalt_timer;
 struct cobalt_sigpending;
 struct cobalt_extref;
 struct siginfo;
+struct xnsched_class;
+union xnsched_policy_param;
 
 struct cobalt_extension {
        struct xnpersonality core;
@@ -53,6 +55,9 @@ struct cobalt_extension {
                                       const struct siginfo *si,
                                       int overrun);
                int (*sched_yield)(struct cobalt_extref *curref);
+               int (*thread_setsched)(struct cobalt_extref *refthread, /* 
nklocked, IRQs off. */
+                                      struct xnsched_class *sched_class,
+                                      union xnsched_policy_param *param);
        } ops;
 };
 
diff --git a/kernel/cobalt/posix/thread.c b/kernel/cobalt/posix/thread.c
index 8516000..c2c4a24 100644
--- a/kernel/cobalt/posix/thread.c
+++ b/kernel/cobalt/posix/thread.c
@@ -717,8 +717,8 @@ pthread_setschedparam_ex(struct cobalt_thread *thread, int 
u_pol, const struct s
        struct xnsched_class *sched_class;
        union xnsched_policy_param param;
        struct xnthread *base_thread;
+       int prio, pol, ret;
        xnticks_t tslice;
-       int prio, pol;
        spl_t s;
 
        xnlock_get_irqsave(&nklock, s);
@@ -797,6 +797,12 @@ pthread_setschedparam_ex(struct cobalt_thread *thread, int 
u_pol, const struct s
                return -EINVAL;
        }
 
+       /*
+        * Updating the scheduling parameter can't fail at this point,
+        * let the extension know.
+        */
+       cobalt_call_extension(thread_setsched, &thread->extref, ret,
+                             sched_class, &param);
        xnthread_set_slice(base_thread, tslice);
        thread->sched_u_policy = u_pol;
        xnthread_set_schedparam(base_thread, sched_class, &param);


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

Reply via email to