[Xenomai-git] Philippe Gerum : cobalt/sched: assoc policy identifier to sched class

2014-10-30 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: f15920c67d075cee304e673ad2b76610dda3b97d
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=f15920c67d075cee304e673ad2b76610dda3b97d

Author: Philippe Gerum 
Date:   Wed Oct 29 10:03:46 2014 +0100

cobalt/sched: assoc policy identifier to sched class

---

 include/cobalt/kernel/sched.h  |1 +
 kernel/cobalt/posix/thread.c   |   10 --
 kernel/cobalt/posix/thread.h   |3 ---
 kernel/cobalt/sched-idle.c |1 +
 kernel/cobalt/sched-quota.c|2 ++
 kernel/cobalt/sched-rt.c   |1 +
 kernel/cobalt/sched-sporadic.c |2 ++
 kernel/cobalt/sched-tp.c   |2 ++
 kernel/cobalt/sched-weak.c |2 ++
 9 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/include/cobalt/kernel/sched.h b/include/cobalt/kernel/sched.h
index 424538b..1ee2aa7 100644
--- a/include/cobalt/kernel/sched.h
+++ b/include/cobalt/kernel/sched.h
@@ -158,6 +158,7 @@ struct xnsched_class {
int nthreads;
struct xnsched_class *next;
int weight;
+   int policy;
const char *name;
 };
 
diff --git a/kernel/cobalt/posix/thread.c b/kernel/cobalt/posix/thread.c
index 27c824b..0786ad3 100644
--- a/kernel/cobalt/posix/thread.c
+++ b/kernel/cobalt/posix/thread.c
@@ -264,7 +264,6 @@ pthread_setschedparam_ex(struct cobalt_thread *thread,
ret = -EINVAL;
goto out;
}
-   thread->sched_u_policy = policy;
xnthread_set_slice(&thread->threadbase, tslice);
if (cobalt_call_extension(thread_setsched, &thread->extref, ret,
  sched_class, ¶m) && ret)
@@ -284,7 +283,6 @@ pthread_getschedparam_ex(struct cobalt_thread *thread,
 {
struct xnsched_class *base_class;
struct xnthread *base_thread;
-   int prio;
spl_t s;
 
xnlock_get_irqsave(&nklock, s);
@@ -297,9 +295,10 @@ pthread_getschedparam_ex(struct cobalt_thread *thread,
 
base_thread = &thread->threadbase;
base_class = base_thread->base_class;
-   *policy_r = thread->sched_u_policy;
-   prio = xnthread_base_priority(base_thread);
-   param_ex->sched_priority = prio;
+   param_ex->sched_priority = xnthread_base_priority(base_thread);
+   *policy_r = base_class->policy;
+   if (param_ex->sched_priority == 0) /* SCHED_FIFO/SCHED_WEAK */
+   *policy_r = SCHED_NORMAL;
 
if (base_class == &xnsched_class_rt) {
if (xnthread_test_state(base_thread, XNRRB))
@@ -379,7 +378,6 @@ static inline int pthread_create(struct cobalt_thread 
**thread_p,
return ret;
}
 
-   thread->sched_u_policy = policy;
thread->magic = COBALT_THREAD_MAGIC;
xnsynch_init(&thread->monitor_synch, XNSYNCH_FIFO, NULL);
 
diff --git a/kernel/cobalt/posix/thread.h b/kernel/cobalt/posix/thread.h
index d1bc034..34dc6cc 100644
--- a/kernel/cobalt/posix/thread.h
+++ b/kernel/cobalt/posix/thread.h
@@ -102,9 +102,6 @@ struct cobalt_thread {
struct xnsynch sigwait;
struct list_head signext;
 
-   /** Cached value for current policy (user side). */
-   int sched_u_policy;
-
/** Monitor wait object and link holder. */
struct xnsynch monitor_synch;
struct list_head monitor_link;
diff --git a/kernel/cobalt/sched-idle.c b/kernel/cobalt/sched-idle.c
index 5127798..8f59c0d 100644
--- a/kernel/cobalt/sched-idle.c
+++ b/kernel/cobalt/sched-idle.c
@@ -56,5 +56,6 @@ struct xnsched_class xnsched_class_idle = {
.sched_getparam =   xnsched_idle_getparam,
.sched_trackprio=   xnsched_idle_trackprio,
.weight =   XNSCHED_CLASS_WEIGHT(0),
+   .policy =   SCHED_IDLE,
.name   =   "idle"
 };
diff --git a/kernel/cobalt/sched-quota.c b/kernel/cobalt/sched-quota.c
index 8a72819..71e2c36 100644
--- a/kernel/cobalt/sched-quota.c
+++ b/kernel/cobalt/sched-quota.c
@@ -19,6 +19,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /*
  * With this policy, each per-CPU scheduler slot maintains a list of
@@ -765,6 +766,7 @@ struct xnsched_class xnsched_class_quota = {
.sched_cleanup_vfile=   xnsched_quota_cleanup_vfile,
 #endif
.weight =   XNSCHED_CLASS_WEIGHT(3),
+   .policy =   SCHED_QUOTA,
.name   =   "quota"
 };
 EXPORT_SYMBOL_GPL(xnsched_class_quota);
diff --git a/kernel/cobalt/sched-rt.c b/kernel/cobalt/sched-rt.c
index 44f90dd..3bd9308 100644
--- a/kernel/cobalt/sched-rt.c
+++ b/kernel/cobalt/sched-rt.c
@@ -246,6 +246,7 @@ struct xnsched_class xnsched_class_rt = {
.sched_cleanup_vfile=   xnsched_rt_cleanup_vfile,
 #endif
.weight =   XNSCHED_CLASS_WEIGHT(4),
+   .policy =   SCHED_FIFO,
.name   =   "rt"
 };
 EXPORT_SYMBOL_GPL(xnsched_class_rt);
diff --git a/kernel/coba

[Xenomai-git] Philippe Gerum : cobalt/sched: assoc policy identifier to sched class

2014-10-29 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: f15920c67d075cee304e673ad2b76610dda3b97d
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=f15920c67d075cee304e673ad2b76610dda3b97d

Author: Philippe Gerum 
Date:   Wed Oct 29 10:03:46 2014 +0100

cobalt/sched: assoc policy identifier to sched class

---

 include/cobalt/kernel/sched.h  |1 +
 kernel/cobalt/posix/thread.c   |   10 --
 kernel/cobalt/posix/thread.h   |3 ---
 kernel/cobalt/sched-idle.c |1 +
 kernel/cobalt/sched-quota.c|2 ++
 kernel/cobalt/sched-rt.c   |1 +
 kernel/cobalt/sched-sporadic.c |2 ++
 kernel/cobalt/sched-tp.c   |2 ++
 kernel/cobalt/sched-weak.c |2 ++
 9 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/include/cobalt/kernel/sched.h b/include/cobalt/kernel/sched.h
index 424538b..1ee2aa7 100644
--- a/include/cobalt/kernel/sched.h
+++ b/include/cobalt/kernel/sched.h
@@ -158,6 +158,7 @@ struct xnsched_class {
int nthreads;
struct xnsched_class *next;
int weight;
+   int policy;
const char *name;
 };
 
diff --git a/kernel/cobalt/posix/thread.c b/kernel/cobalt/posix/thread.c
index 27c824b..0786ad3 100644
--- a/kernel/cobalt/posix/thread.c
+++ b/kernel/cobalt/posix/thread.c
@@ -264,7 +264,6 @@ pthread_setschedparam_ex(struct cobalt_thread *thread,
ret = -EINVAL;
goto out;
}
-   thread->sched_u_policy = policy;
xnthread_set_slice(&thread->threadbase, tslice);
if (cobalt_call_extension(thread_setsched, &thread->extref, ret,
  sched_class, ¶m) && ret)
@@ -284,7 +283,6 @@ pthread_getschedparam_ex(struct cobalt_thread *thread,
 {
struct xnsched_class *base_class;
struct xnthread *base_thread;
-   int prio;
spl_t s;
 
xnlock_get_irqsave(&nklock, s);
@@ -297,9 +295,10 @@ pthread_getschedparam_ex(struct cobalt_thread *thread,
 
base_thread = &thread->threadbase;
base_class = base_thread->base_class;
-   *policy_r = thread->sched_u_policy;
-   prio = xnthread_base_priority(base_thread);
-   param_ex->sched_priority = prio;
+   param_ex->sched_priority = xnthread_base_priority(base_thread);
+   *policy_r = base_class->policy;
+   if (param_ex->sched_priority == 0) /* SCHED_FIFO/SCHED_WEAK */
+   *policy_r = SCHED_NORMAL;
 
if (base_class == &xnsched_class_rt) {
if (xnthread_test_state(base_thread, XNRRB))
@@ -379,7 +378,6 @@ static inline int pthread_create(struct cobalt_thread 
**thread_p,
return ret;
}
 
-   thread->sched_u_policy = policy;
thread->magic = COBALT_THREAD_MAGIC;
xnsynch_init(&thread->monitor_synch, XNSYNCH_FIFO, NULL);
 
diff --git a/kernel/cobalt/posix/thread.h b/kernel/cobalt/posix/thread.h
index d1bc034..34dc6cc 100644
--- a/kernel/cobalt/posix/thread.h
+++ b/kernel/cobalt/posix/thread.h
@@ -102,9 +102,6 @@ struct cobalt_thread {
struct xnsynch sigwait;
struct list_head signext;
 
-   /** Cached value for current policy (user side). */
-   int sched_u_policy;
-
/** Monitor wait object and link holder. */
struct xnsynch monitor_synch;
struct list_head monitor_link;
diff --git a/kernel/cobalt/sched-idle.c b/kernel/cobalt/sched-idle.c
index 5127798..8f59c0d 100644
--- a/kernel/cobalt/sched-idle.c
+++ b/kernel/cobalt/sched-idle.c
@@ -56,5 +56,6 @@ struct xnsched_class xnsched_class_idle = {
.sched_getparam =   xnsched_idle_getparam,
.sched_trackprio=   xnsched_idle_trackprio,
.weight =   XNSCHED_CLASS_WEIGHT(0),
+   .policy =   SCHED_IDLE,
.name   =   "idle"
 };
diff --git a/kernel/cobalt/sched-quota.c b/kernel/cobalt/sched-quota.c
index 8a72819..71e2c36 100644
--- a/kernel/cobalt/sched-quota.c
+++ b/kernel/cobalt/sched-quota.c
@@ -19,6 +19,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /*
  * With this policy, each per-CPU scheduler slot maintains a list of
@@ -765,6 +766,7 @@ struct xnsched_class xnsched_class_quota = {
.sched_cleanup_vfile=   xnsched_quota_cleanup_vfile,
 #endif
.weight =   XNSCHED_CLASS_WEIGHT(3),
+   .policy =   SCHED_QUOTA,
.name   =   "quota"
 };
 EXPORT_SYMBOL_GPL(xnsched_class_quota);
diff --git a/kernel/cobalt/sched-rt.c b/kernel/cobalt/sched-rt.c
index 44f90dd..3bd9308 100644
--- a/kernel/cobalt/sched-rt.c
+++ b/kernel/cobalt/sched-rt.c
@@ -246,6 +246,7 @@ struct xnsched_class xnsched_class_rt = {
.sched_cleanup_vfile=   xnsched_rt_cleanup_vfile,
 #endif
.weight =   XNSCHED_CLASS_WEIGHT(4),
+   .policy =   SCHED_FIFO,
.name   =   "rt"
 };
 EXPORT_SYMBOL_GPL(xnsched_class_rt);
diff --git a/kernel/cobalt