[Xenomai-git] Philippe Gerum : lib/cobalt: wrap sched_setscheduler(2)
Module: xenomai-3 Branch: master Commit: 08fde44697b24c0be0c40ea33a6d19d4e6049922 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=08fde44697b24c0be0c40ea33a6d19d4e6049922 Author: Philippe Gerum Date: Thu Sep 17 01:30:52 2015 +0200 lib/cobalt: wrap sched_setscheduler(2) --- include/cobalt/sched.h | 12 +++- lib/cobalt/cobalt.wrappers |1 + lib/cobalt/init.c |4 +- lib/cobalt/internal.h |3 + lib/cobalt/sched.c | 157 lib/cobalt/thread.c| 45 - lib/cobalt/wrappers.c |7 ++ 7 files changed, 206 insertions(+), 23 deletions(-) diff --git a/include/cobalt/sched.h b/include/cobalt/sched.h index d7c72ca..12c33e6 100644 --- a/include/cobalt/sched.h +++ b/include/cobalt/sched.h @@ -25,20 +25,26 @@ #include #include +#ifdef __cplusplus +extern "C" { +#endif + COBALT_DECL(int, sched_yield(void)); COBALT_DECL(int, sched_get_priority_min(int policy)); COBALT_DECL(int, sched_get_priority_max(int policy)); -#ifdef __cplusplus -extern "C" { -#endif +COBALT_DECL(int, sched_setscheduler(pid_t pid, int policy, + const struct sched_param *param)); int sched_get_priority_min_ex(int policy); int sched_get_priority_max_ex(int policy); +int sched_setscheduler_ex(pid_t pid, int policy, + const struct sched_param_ex *param_ex); + int sched_setconfig_np(int cpu, int policy, const union sched_config *config, size_t len); diff --git a/lib/cobalt/cobalt.wrappers b/lib/cobalt/cobalt.wrappers index 4968340..c8e24cb 100644 --- a/lib/cobalt/cobalt.wrappers +++ b/lib/cobalt/cobalt.wrappers @@ -6,6 +6,7 @@ --wrap sched_yield --wrap sched_get_priority_min --wrap sched_get_priority_max +--wrap sched_setscheduler --wrap pthread_kill --wrap pthread_join --wrap pthread_setname_np diff --git a/lib/cobalt/init.c b/lib/cobalt/init.c index acad534..8a48428 100644 --- a/lib/cobalt/init.c +++ b/lib/cobalt/init.c @@ -199,7 +199,7 @@ int cobalt_init(void) ret = __STD(pthread_getschedparam(ptid, &policy, &parm)); if (ret) { early_warning("pthread_getschedparam failed"); - return ret; + return -ret; } /* @@ -224,7 +224,7 @@ int cobalt_init(void) if (ret) { early_warning("pthread_setschedparam failed (prio=%d)", __cobalt_main_prio); - return ret; + return -ret; } return 0; diff --git a/lib/cobalt/internal.h b/lib/cobalt/internal.h index df7d416..540c286 100644 --- a/lib/cobalt/internal.h +++ b/lib/cobalt/internal.h @@ -55,6 +55,9 @@ void cobalt_default_mutexattr_init(void); void cobalt_default_condattr_init(void); +int cobalt_xlate_schedparam(int policy, + const struct sched_param_ex *param_ex, + struct sched_param *param); int cobalt_init(void); struct cobalt_featinfo; diff --git a/lib/cobalt/sched.c b/lib/cobalt/sched.c index b0be725..d1abed8 100644 --- a/lib/cobalt/sched.c +++ b/lib/cobalt/sched.c @@ -172,6 +172,163 @@ COBALT_IMPL(int, sched_get_priority_max, (int policy)) } /** + * Set the scheduling policy and parameters of the specified process. + * + * This service set the scheduling policy of the Xenomai process + * identified by @a pid to the value @a pol, and its scheduling + * parameters (i.e. its priority) to the value pointed to by @a par. + * + * If the current Linux thread ID is passed (see gettid(2)), this + * service turns the current thread into a Xenomai thread. If @a pid + * is neither the identifier of the current thread nor the identifier + * of an existing Xenomai thread, this service falls back to the + * regular sched_setscheduler() service, causing a transition to + * secondary mode if the caller is a Xenomai thread. + * + * @param pid target process/thread; + * + * @param policy scheduling policy, one of SCHED_FIFO, SCHED_RR, or + * SCHED_OTHER; + * + * @param param scheduling parameters address. + * + * @return 0 on success; + * @return an error number if: + * - ESRCH, @a pid is invalid; + * - EINVAL, @a pol or @a par->sched_priority is invalid; + * - EFAULT, @a par is an invalid address; + * + * @see + * http://www.opengroup.org/onlinepubs/95399/functions/sched_setscheduler.html";> + * Specification. + * + * @note + * + * When creating or shadowing a Xenomai thread for the first time, + * libcobalt installs an internal handler for the SIGSHADOW signal. If + * you had previously installed a handler for such signal before that + * point, such handler will be exclusively called for any SIGSHADOW + * occurrence Xenomai did not send. + * + * If, however, an application-defined handler for SIGSHADOW is + * installed afterwards, overriding the libcobalt handler, the new + * handler is required to call cobalt_sigshadow_handler() on + * entry. This routine
[Xenomai-git] Philippe Gerum : lib/cobalt: wrap sched_setscheduler(2)
Module: xenomai-3 Branch: arm64 Commit: 08fde44697b24c0be0c40ea33a6d19d4e6049922 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=08fde44697b24c0be0c40ea33a6d19d4e6049922 Author: Philippe Gerum Date: Thu Sep 17 01:30:52 2015 +0200 lib/cobalt: wrap sched_setscheduler(2) --- include/cobalt/sched.h | 12 +++- lib/cobalt/cobalt.wrappers |1 + lib/cobalt/init.c |4 +- lib/cobalt/internal.h |3 + lib/cobalt/sched.c | 157 lib/cobalt/thread.c| 45 - lib/cobalt/wrappers.c |7 ++ 7 files changed, 206 insertions(+), 23 deletions(-) diff --git a/include/cobalt/sched.h b/include/cobalt/sched.h index d7c72ca..12c33e6 100644 --- a/include/cobalt/sched.h +++ b/include/cobalt/sched.h @@ -25,20 +25,26 @@ #include #include +#ifdef __cplusplus +extern "C" { +#endif + COBALT_DECL(int, sched_yield(void)); COBALT_DECL(int, sched_get_priority_min(int policy)); COBALT_DECL(int, sched_get_priority_max(int policy)); -#ifdef __cplusplus -extern "C" { -#endif +COBALT_DECL(int, sched_setscheduler(pid_t pid, int policy, + const struct sched_param *param)); int sched_get_priority_min_ex(int policy); int sched_get_priority_max_ex(int policy); +int sched_setscheduler_ex(pid_t pid, int policy, + const struct sched_param_ex *param_ex); + int sched_setconfig_np(int cpu, int policy, const union sched_config *config, size_t len); diff --git a/lib/cobalt/cobalt.wrappers b/lib/cobalt/cobalt.wrappers index 4968340..c8e24cb 100644 --- a/lib/cobalt/cobalt.wrappers +++ b/lib/cobalt/cobalt.wrappers @@ -6,6 +6,7 @@ --wrap sched_yield --wrap sched_get_priority_min --wrap sched_get_priority_max +--wrap sched_setscheduler --wrap pthread_kill --wrap pthread_join --wrap pthread_setname_np diff --git a/lib/cobalt/init.c b/lib/cobalt/init.c index acad534..8a48428 100644 --- a/lib/cobalt/init.c +++ b/lib/cobalt/init.c @@ -199,7 +199,7 @@ int cobalt_init(void) ret = __STD(pthread_getschedparam(ptid, &policy, &parm)); if (ret) { early_warning("pthread_getschedparam failed"); - return ret; + return -ret; } /* @@ -224,7 +224,7 @@ int cobalt_init(void) if (ret) { early_warning("pthread_setschedparam failed (prio=%d)", __cobalt_main_prio); - return ret; + return -ret; } return 0; diff --git a/lib/cobalt/internal.h b/lib/cobalt/internal.h index df7d416..540c286 100644 --- a/lib/cobalt/internal.h +++ b/lib/cobalt/internal.h @@ -55,6 +55,9 @@ void cobalt_default_mutexattr_init(void); void cobalt_default_condattr_init(void); +int cobalt_xlate_schedparam(int policy, + const struct sched_param_ex *param_ex, + struct sched_param *param); int cobalt_init(void); struct cobalt_featinfo; diff --git a/lib/cobalt/sched.c b/lib/cobalt/sched.c index b0be725..d1abed8 100644 --- a/lib/cobalt/sched.c +++ b/lib/cobalt/sched.c @@ -172,6 +172,163 @@ COBALT_IMPL(int, sched_get_priority_max, (int policy)) } /** + * Set the scheduling policy and parameters of the specified process. + * + * This service set the scheduling policy of the Xenomai process + * identified by @a pid to the value @a pol, and its scheduling + * parameters (i.e. its priority) to the value pointed to by @a par. + * + * If the current Linux thread ID is passed (see gettid(2)), this + * service turns the current thread into a Xenomai thread. If @a pid + * is neither the identifier of the current thread nor the identifier + * of an existing Xenomai thread, this service falls back to the + * regular sched_setscheduler() service, causing a transition to + * secondary mode if the caller is a Xenomai thread. + * + * @param pid target process/thread; + * + * @param policy scheduling policy, one of SCHED_FIFO, SCHED_RR, or + * SCHED_OTHER; + * + * @param param scheduling parameters address. + * + * @return 0 on success; + * @return an error number if: + * - ESRCH, @a pid is invalid; + * - EINVAL, @a pol or @a par->sched_priority is invalid; + * - EFAULT, @a par is an invalid address; + * + * @see + * http://www.opengroup.org/onlinepubs/95399/functions/sched_setscheduler.html";> + * Specification. + * + * @note + * + * When creating or shadowing a Xenomai thread for the first time, + * libcobalt installs an internal handler for the SIGSHADOW signal. If + * you had previously installed a handler for such signal before that + * point, such handler will be exclusively called for any SIGSHADOW + * occurrence Xenomai did not send. + * + * If, however, an application-defined handler for SIGSHADOW is + * installed afterwards, overriding the libcobalt handler, the new + * handler is required to call cobalt_sigshadow_handler() on + * entry. This routine
[Xenomai-git] Philippe Gerum : lib/cobalt: wrap sched_setscheduler(2)
Module: xenomai-3 Branch: next Commit: 08fde44697b24c0be0c40ea33a6d19d4e6049922 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=08fde44697b24c0be0c40ea33a6d19d4e6049922 Author: Philippe Gerum Date: Thu Sep 17 01:30:52 2015 +0200 lib/cobalt: wrap sched_setscheduler(2) --- include/cobalt/sched.h | 12 +++- lib/cobalt/cobalt.wrappers |1 + lib/cobalt/init.c |4 +- lib/cobalt/internal.h |3 + lib/cobalt/sched.c | 157 lib/cobalt/thread.c| 45 - lib/cobalt/wrappers.c |7 ++ 7 files changed, 206 insertions(+), 23 deletions(-) diff --git a/include/cobalt/sched.h b/include/cobalt/sched.h index d7c72ca..12c33e6 100644 --- a/include/cobalt/sched.h +++ b/include/cobalt/sched.h @@ -25,20 +25,26 @@ #include #include +#ifdef __cplusplus +extern "C" { +#endif + COBALT_DECL(int, sched_yield(void)); COBALT_DECL(int, sched_get_priority_min(int policy)); COBALT_DECL(int, sched_get_priority_max(int policy)); -#ifdef __cplusplus -extern "C" { -#endif +COBALT_DECL(int, sched_setscheduler(pid_t pid, int policy, + const struct sched_param *param)); int sched_get_priority_min_ex(int policy); int sched_get_priority_max_ex(int policy); +int sched_setscheduler_ex(pid_t pid, int policy, + const struct sched_param_ex *param_ex); + int sched_setconfig_np(int cpu, int policy, const union sched_config *config, size_t len); diff --git a/lib/cobalt/cobalt.wrappers b/lib/cobalt/cobalt.wrappers index 4968340..c8e24cb 100644 --- a/lib/cobalt/cobalt.wrappers +++ b/lib/cobalt/cobalt.wrappers @@ -6,6 +6,7 @@ --wrap sched_yield --wrap sched_get_priority_min --wrap sched_get_priority_max +--wrap sched_setscheduler --wrap pthread_kill --wrap pthread_join --wrap pthread_setname_np diff --git a/lib/cobalt/init.c b/lib/cobalt/init.c index acad534..8a48428 100644 --- a/lib/cobalt/init.c +++ b/lib/cobalt/init.c @@ -199,7 +199,7 @@ int cobalt_init(void) ret = __STD(pthread_getschedparam(ptid, &policy, &parm)); if (ret) { early_warning("pthread_getschedparam failed"); - return ret; + return -ret; } /* @@ -224,7 +224,7 @@ int cobalt_init(void) if (ret) { early_warning("pthread_setschedparam failed (prio=%d)", __cobalt_main_prio); - return ret; + return -ret; } return 0; diff --git a/lib/cobalt/internal.h b/lib/cobalt/internal.h index df7d416..540c286 100644 --- a/lib/cobalt/internal.h +++ b/lib/cobalt/internal.h @@ -55,6 +55,9 @@ void cobalt_default_mutexattr_init(void); void cobalt_default_condattr_init(void); +int cobalt_xlate_schedparam(int policy, + const struct sched_param_ex *param_ex, + struct sched_param *param); int cobalt_init(void); struct cobalt_featinfo; diff --git a/lib/cobalt/sched.c b/lib/cobalt/sched.c index b0be725..d1abed8 100644 --- a/lib/cobalt/sched.c +++ b/lib/cobalt/sched.c @@ -172,6 +172,163 @@ COBALT_IMPL(int, sched_get_priority_max, (int policy)) } /** + * Set the scheduling policy and parameters of the specified process. + * + * This service set the scheduling policy of the Xenomai process + * identified by @a pid to the value @a pol, and its scheduling + * parameters (i.e. its priority) to the value pointed to by @a par. + * + * If the current Linux thread ID is passed (see gettid(2)), this + * service turns the current thread into a Xenomai thread. If @a pid + * is neither the identifier of the current thread nor the identifier + * of an existing Xenomai thread, this service falls back to the + * regular sched_setscheduler() service, causing a transition to + * secondary mode if the caller is a Xenomai thread. + * + * @param pid target process/thread; + * + * @param policy scheduling policy, one of SCHED_FIFO, SCHED_RR, or + * SCHED_OTHER; + * + * @param param scheduling parameters address. + * + * @return 0 on success; + * @return an error number if: + * - ESRCH, @a pid is invalid; + * - EINVAL, @a pol or @a par->sched_priority is invalid; + * - EFAULT, @a par is an invalid address; + * + * @see + * http://www.opengroup.org/onlinepubs/95399/functions/sched_setscheduler.html";> + * Specification. + * + * @note + * + * When creating or shadowing a Xenomai thread for the first time, + * libcobalt installs an internal handler for the SIGSHADOW signal. If + * you had previously installed a handler for such signal before that + * point, such handler will be exclusively called for any SIGSHADOW + * occurrence Xenomai did not send. + * + * If, however, an application-defined handler for SIGSHADOW is + * installed afterwards, overriding the libcobalt handler, the new + * handler is required to call cobalt_sigshadow_handler() on + * entry. This routine r