[Xenomai-git] Philippe Gerum : cobalt: generalize support for extended scheduling attributes

2011-11-10 Thread GIT version control
Module: xenomai-forge
Branch: master
Commit: 0e883200a0cae37e954a484a42da2dbfbc658284
URL:
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=0e883200a0cae37e954a484a42da2dbfbc658284

Author: Philippe Gerum r...@xenomai.org
Date:   Thu Nov 10 16:31:56 2011 +0100

cobalt: generalize support for extended scheduling attributes

We provide the necessary bits to create threads from userland within
Cobalt-specific scheduling classes, like SCHED_COBALT, SCHED_SPORADIC
or SCHED_TP.

To this end, we introduce pthread_create_ex(), which accepts an
extended thread attribute structure to hold the class-specific
parameters. In addition, a set of attribute accessors for this
structure is also provided, as a collection of pthread_attr_*_ex()
calls.

pthread_create() is internally rebased on pthread_create_ex(), and the
kernel support for creating Cobalt shadows is changed to accept the
extended attribute set.

---

 include/cobalt/pthread.h |  141 +
 kernel/cobalt/syscall.c  |   39 ---
 lib/cobalt/Makefile.am   |1 +
 lib/cobalt/Makefile.in   |   28 --
 lib/cobalt/attr.c|  121 +
 lib/cobalt/thread.c  |  261 +
 6 files changed, 408 insertions(+), 183 deletions(-)

diff --git a/include/cobalt/pthread.h b/include/cobalt/pthread.h
index 955a6b4..acfda12 100644
--- a/include/cobalt/pthread.h
+++ b/include/cobalt/pthread.h
@@ -258,11 +258,11 @@ int pthread_attr_getfp_np(const pthread_attr_t *attr,
 int pthread_attr_setfp_np(pthread_attr_t *attr,
  int use_fp);
 
-int pthread_attr_getaffinity_np (const pthread_attr_t *attr,
-xnarch_cpumask_t *mask);
+int pthread_attr_getaffinity_np(const pthread_attr_t *attr,
+   xnarch_cpumask_t *mask);
 
-int pthread_attr_setaffinity_np (pthread_attr_t *attr,
-xnarch_cpumask_t mask);
+int pthread_attr_setaffinity_np(pthread_attr_t *attr,
+   xnarch_cpumask_t mask);
 
 int pthread_create(pthread_t *tid,
   const pthread_attr_t *attr,
@@ -408,49 +408,18 @@ int pthread_set_name_np(pthread_t thread,
 
 #else /* !(__KERNEL__ || __XENO_SIM__) */
 
+typedef struct {
+   pthread_attr_t std;
+   struct {
+   int sched_policy;
+   struct sched_param_ex sched_param;
+   } nonstd;
+} pthread_attr_ex_t;
+
 #ifdef __cplusplus
 extern C {
 #endif
 
-#ifndef HAVE_PTHREAD_MUTEXATTR_SETPROTOCOL
-int pthread_mutexattr_getprotocol(const pthread_mutexattr_t *attr,
- int *proto);
-
-int pthread_mutexattr_setprotocol(pthread_mutexattr_t *attr,
- int proto);
-#endif
-
-#ifndef HAVE_PTHREAD_CONDATTR_SETCLOCK
-int pthread_condattr_getclock(const pthread_condattr_t *attr,
- clockid_t *clk_id);
-
-int pthread_condattr_setclock(pthread_condattr_t *attr,
- clockid_t clk_id);
-#endif
-
-int pthread_make_periodic_np(pthread_t thread,
-clockid_t clk_id,
-struct timespec *starttp,
-struct timespec *periodtp);
-
-int pthread_wait_np(unsigned long *overruns_r);
-
-int pthread_set_mode_np(int clrmask, int setmask,
-   int *mask_r);
-
-int pthread_set_name_np(pthread_t thread,
-   const char *name);
-
-int pthread_probe_np(pid_t tid);
-
-int pthread_getschedparam_ex(pthread_t tid,
-int *pol,
-struct sched_param_ex *par);
-
-int pthread_setschedparam_ex(pthread_t tid,
-int pol,
-const struct sched_param_ex *par);
-
 COBALT_DECL(int, pthread_attr_setschedpolicy(pthread_attr_t *attr,
 int policy));
 
@@ -545,6 +514,92 @@ COBALT_DECL(int, pthread_cond_broadcast(pthread_cond_t 
*cond));
 
 COBALT_DECL(int, pthread_kill(pthread_t tid, int sig));
 
+#ifndef HAVE_PTHREAD_MUTEXATTR_SETPROTOCOL
+COBALT_DECL(int, pthread_mutexattr_getprotocol(const pthread_mutexattr_t *attr,
+  int *proto));
+
+COBALT_DECL(int, pthread_mutexattr_setprotocol(pthread_mutexattr_t *attr,
+  int proto));
+#endif
+
+#ifndef HAVE_PTHREAD_CONDATTR_SETCLOCK
+COBALT_DECL(int, pthread_condattr_getclock(const pthread_condattr_t *attr,
+  clockid_t *clk_id));
+
+COBALT_DECL(int pthread_condattr_setclock(pthread_condattr_t *attr,
+ clockid_t clk_id));
+#endif
+
+int pthread_make_periodic_np(pthread_t thread,
+clockid_t clk_id,
+struct timespec *starttp,
+struct timespec *periodtp);
+
+int pthread_wait_np(unsigned long 

[Xenomai-git] Philippe Gerum : cobalt: generalize support for extended scheduling attributes

2011-11-10 Thread GIT version control
Module: xenomai-gch
Branch: for-forge
Commit: 0e883200a0cae37e954a484a42da2dbfbc658284
URL:
http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=0e883200a0cae37e954a484a42da2dbfbc658284

Author: Philippe Gerum r...@xenomai.org
Date:   Thu Nov 10 16:31:56 2011 +0100

cobalt: generalize support for extended scheduling attributes

We provide the necessary bits to create threads from userland within
Cobalt-specific scheduling classes, like SCHED_COBALT, SCHED_SPORADIC
or SCHED_TP.

To this end, we introduce pthread_create_ex(), which accepts an
extended thread attribute structure to hold the class-specific
parameters. In addition, a set of attribute accessors for this
structure is also provided, as a collection of pthread_attr_*_ex()
calls.

pthread_create() is internally rebased on pthread_create_ex(), and the
kernel support for creating Cobalt shadows is changed to accept the
extended attribute set.

---

 include/cobalt/pthread.h |  141 +
 kernel/cobalt/syscall.c  |   39 ---
 lib/cobalt/Makefile.am   |1 +
 lib/cobalt/Makefile.in   |   28 --
 lib/cobalt/attr.c|  121 +
 lib/cobalt/thread.c  |  261 +
 6 files changed, 408 insertions(+), 183 deletions(-)

diff --git a/include/cobalt/pthread.h b/include/cobalt/pthread.h
index 955a6b4..acfda12 100644
--- a/include/cobalt/pthread.h
+++ b/include/cobalt/pthread.h
@@ -258,11 +258,11 @@ int pthread_attr_getfp_np(const pthread_attr_t *attr,
 int pthread_attr_setfp_np(pthread_attr_t *attr,
  int use_fp);
 
-int pthread_attr_getaffinity_np (const pthread_attr_t *attr,
-xnarch_cpumask_t *mask);
+int pthread_attr_getaffinity_np(const pthread_attr_t *attr,
+   xnarch_cpumask_t *mask);
 
-int pthread_attr_setaffinity_np (pthread_attr_t *attr,
-xnarch_cpumask_t mask);
+int pthread_attr_setaffinity_np(pthread_attr_t *attr,
+   xnarch_cpumask_t mask);
 
 int pthread_create(pthread_t *tid,
   const pthread_attr_t *attr,
@@ -408,49 +408,18 @@ int pthread_set_name_np(pthread_t thread,
 
 #else /* !(__KERNEL__ || __XENO_SIM__) */
 
+typedef struct {
+   pthread_attr_t std;
+   struct {
+   int sched_policy;
+   struct sched_param_ex sched_param;
+   } nonstd;
+} pthread_attr_ex_t;
+
 #ifdef __cplusplus
 extern C {
 #endif
 
-#ifndef HAVE_PTHREAD_MUTEXATTR_SETPROTOCOL
-int pthread_mutexattr_getprotocol(const pthread_mutexattr_t *attr,
- int *proto);
-
-int pthread_mutexattr_setprotocol(pthread_mutexattr_t *attr,
- int proto);
-#endif
-
-#ifndef HAVE_PTHREAD_CONDATTR_SETCLOCK
-int pthread_condattr_getclock(const pthread_condattr_t *attr,
- clockid_t *clk_id);
-
-int pthread_condattr_setclock(pthread_condattr_t *attr,
- clockid_t clk_id);
-#endif
-
-int pthread_make_periodic_np(pthread_t thread,
-clockid_t clk_id,
-struct timespec *starttp,
-struct timespec *periodtp);
-
-int pthread_wait_np(unsigned long *overruns_r);
-
-int pthread_set_mode_np(int clrmask, int setmask,
-   int *mask_r);
-
-int pthread_set_name_np(pthread_t thread,
-   const char *name);
-
-int pthread_probe_np(pid_t tid);
-
-int pthread_getschedparam_ex(pthread_t tid,
-int *pol,
-struct sched_param_ex *par);
-
-int pthread_setschedparam_ex(pthread_t tid,
-int pol,
-const struct sched_param_ex *par);
-
 COBALT_DECL(int, pthread_attr_setschedpolicy(pthread_attr_t *attr,
 int policy));
 
@@ -545,6 +514,92 @@ COBALT_DECL(int, pthread_cond_broadcast(pthread_cond_t 
*cond));
 
 COBALT_DECL(int, pthread_kill(pthread_t tid, int sig));
 
+#ifndef HAVE_PTHREAD_MUTEXATTR_SETPROTOCOL
+COBALT_DECL(int, pthread_mutexattr_getprotocol(const pthread_mutexattr_t *attr,
+  int *proto));
+
+COBALT_DECL(int, pthread_mutexattr_setprotocol(pthread_mutexattr_t *attr,
+  int proto));
+#endif
+
+#ifndef HAVE_PTHREAD_CONDATTR_SETCLOCK
+COBALT_DECL(int, pthread_condattr_getclock(const pthread_condattr_t *attr,
+  clockid_t *clk_id));
+
+COBALT_DECL(int pthread_condattr_setclock(pthread_condattr_t *attr,
+ clockid_t clk_id));
+#endif
+
+int pthread_make_periodic_np(pthread_t thread,
+clockid_t clk_id,
+struct timespec *starttp,
+struct timespec *periodtp);
+
+int pthread_wait_np(unsigned long