Module: xenomai-forge Branch: next Commit: d5d345676e9c18c7d3a8c4e544032f37370047d1 URL: http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=d5d345676e9c18c7d3a8c4e544032f37370047d1
Author: Philippe Gerum <r...@xenomai.org> Date: Mon May 26 11:58:32 2014 +0200 cobalt/posix/sched: introduce syscall to compute weighted priorities --- include/cobalt/uapi/syscall.h | 3 ++- kernel/cobalt/posix/syscall.c | 1 + kernel/cobalt/posix/thread.c | 30 +++++++++++++++++++++++++++--- kernel/cobalt/posix/thread.h | 5 ++++- 4 files changed, 34 insertions(+), 5 deletions(-) diff --git a/include/cobalt/uapi/syscall.h b/include/cobalt/uapi/syscall.h index a47d520..50d068f 100644 --- a/include/cobalt/uapi/syscall.h +++ b/include/cobalt/uapi/syscall.h @@ -23,7 +23,8 @@ #define COBALT_BINDING_MAGIC 0x50534531 #define sc_cobalt_thread_create 0 -/* 1-2 unimplemented */ +/* 1 unimplemented */ +#define sc_cobalt_sched_weightprio 2 #define sc_cobalt_sched_yield 3 #define sc_cobalt_thread_make_periodic 4 #define sc_cobalt_thread_wait 5 diff --git a/kernel/cobalt/posix/syscall.c b/kernel/cobalt/posix/syscall.c index 7e9b93a..c5ef315 100644 --- a/kernel/cobalt/posix/syscall.c +++ b/kernel/cobalt/posix/syscall.c @@ -90,6 +90,7 @@ static struct xnsyscall cobalt_syscalls[] = { SKINCALL_DEF(sc_cobalt_thread_create, cobalt_thread_create, init), SKINCALL_DEF(sc_cobalt_thread_setschedparam_ex, cobalt_thread_setschedparam_ex, conforming), SKINCALL_DEF(sc_cobalt_thread_getschedparam_ex, cobalt_thread_getschedparam_ex, any), + SKINCALL_DEF(sc_cobalt_sched_weightprio, cobalt_sched_weighted_prio, any), SKINCALL_DEF(sc_cobalt_sched_yield, cobalt_sched_yield, primary), SKINCALL_DEF(sc_cobalt_thread_make_periodic, cobalt_thread_make_periodic_np, conforming), SKINCALL_DEF(sc_cobalt_thread_wait, cobalt_thread_wait_np, primary), diff --git a/kernel/cobalt/posix/thread.c b/kernel/cobalt/posix/thread.c index 5db7fea..b9c6d80 100644 --- a/kernel/cobalt/posix/thread.c +++ b/kernel/cobalt/posix/thread.c @@ -303,7 +303,7 @@ get_policy_param(union xnsched_policy_param *param, case SCHED_RR: /* if unspecified, use current one. */ tslice = ts2ns(¶m_ex->sched_rr_quantum); - if (tslice == XN_INFINITE) + if (tslice == XN_INFINITE && tslice_r) tslice = *tslice_r; /* falldown wanted */ case SCHED_FIFO: @@ -345,7 +345,8 @@ get_policy_param(union xnsched_policy_param *param, return NULL; } - *tslice_r = tslice; + if (tslice_r) + *tslice_r = tslice; return sched_class; } @@ -811,7 +812,7 @@ static inline int pthread_set_mode_np(int clrmask, int setmask, int *mode_r) */ int cobalt_thread_setschedparam_ex(unsigned long pth, int policy, - struct sched_param_ex __user *u_param, + const struct sched_param_ex __user *u_param, unsigned long __user *u_window_offset, int __user *u_promoted) { @@ -1756,4 +1757,27 @@ ssize_t cobalt_sched_getconfig_np(int cpu, int policy, return ret; } +int cobalt_sched_weighted_prio(int policy, + const struct sched_param_ex __user *u_param) +{ + struct xnsched_class *sched_class; + union xnsched_policy_param param; + struct sched_param_ex param_ex; + int prio; + + if (__xn_safe_copy_from_user(¶m_ex, u_param, sizeof(param_ex))) + return -EFAULT; + + sched_class = get_policy_param(¶m, policy, ¶m_ex, NULL); + if (sched_class == NULL) + return -EINVAL; + + prio = param_ex.sched_priority; + if (prio < 0) + prio = -prio; + + return prio + sched_class->weight; +} + /*@}*/ + diff --git a/kernel/cobalt/posix/thread.h b/kernel/cobalt/posix/thread.h index b68336e..5b1a45d 100644 --- a/kernel/cobalt/posix/thread.h +++ b/kernel/cobalt/posix/thread.h @@ -160,7 +160,7 @@ int cobalt_thread_stat(pid_t pid, int cobalt_thread_setschedparam_ex(unsigned long tid, int policy, - struct sched_param_ex __user *u_param, + const struct sched_param_ex __user *u_param, unsigned long __user *u_window_offset, int __user *u_promoted); @@ -170,6 +170,9 @@ int cobalt_thread_getschedparam_ex(unsigned long tid, int cobalt_sched_yield(void); +int cobalt_sched_weighted_prio(int policy, + const struct sched_param_ex __user *u_param); + int cobalt_sched_min_prio(int policy); int cobalt_sched_max_prio(int policy); _______________________________________________ Xenomai-git mailing list Xenomai-git@xenomai.org http://www.xenomai.org/mailman/listinfo/xenomai-git