Module: xenomai-forge Branch: master Commit: b382126f929fbca9074a057336f0e2271d5d440c URL: http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=b382126f929fbca9074a057336f0e2271d5d440c
Author: Philippe Gerum <r...@xenomai.org> Date: Mon Nov 21 23:11:18 2011 +0100 copperplate/threadobj: fix priority update over Cobalt --- include/copperplate/threadobj.h | 2 +- lib/copperplate/threadobj.c | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/include/copperplate/threadobj.h b/include/copperplate/threadobj.h index c2bf675..5d6410c 100644 --- a/include/copperplate/threadobj.h +++ b/include/copperplate/threadobj.h @@ -57,7 +57,6 @@ struct threadobj_stat { struct threadobj_corespec { int prio_unlocked; struct notifier notifier; - struct timespec tslice; struct timespec wakeup; ticks_t period; }; @@ -133,6 +132,7 @@ struct threadobj { size_t wait_size; struct threadobj_corespec core; + struct timespec tslice; pthread_cond_t barrier; struct traceobj *tracer; struct pvholder thread_link; diff --git a/lib/copperplate/threadobj.c b/lib/copperplate/threadobj.c index 6508812..11cc571 100644 --- a/lib/copperplate/threadobj.c +++ b/lib/copperplate/threadobj.c @@ -240,8 +240,8 @@ int threadobj_unlock_sched(struct threadobj *thobj) /* thobj->lock held */ int threadobj_set_priority(struct threadobj *thobj, int prio) /* thobj->lock held */ { + struct sched_param_ex xparam; pthread_t tid = thobj->tid; - struct sched_param param; int ret, policy; thobj->priority = prio; @@ -249,8 +249,10 @@ int threadobj_set_priority(struct threadobj *thobj, int prio) /* thobj->lock hel if (prio == 0) { thobj->status &= ~THREADOBJ_ROUNDROBIN; policy = SCHED_OTHER; - } else if (thobj->status & THREADOBJ_ROUNDROBIN) + } else if (thobj->status & THREADOBJ_ROUNDROBIN) { + xparam.sched_rr_quantum = thobj->tslice; policy = SCHED_RR; + } threadobj_unlock(thobj); /* @@ -258,8 +260,8 @@ int threadobj_set_priority(struct threadobj *thobj, int prio) /* thobj->lock hel * time credit for the target thread with the last rrperiod * set. */ - param.sched_priority = prio; - ret = __RT(pthread_setschedparam(tid, policy, ¶m)); + xparam.sched_priority = prio; + ret = pthread_setschedparam_ex(tid, policy, &xparam); threadobj_lock(thobj); return __bt(-ret); @@ -304,6 +306,7 @@ static int set_rr(struct threadobj *thobj, struct timespec *quantum) xparam.sched_rr_quantum.tv_nsec = 0; thobj->status &= ~THREADOBJ_ROUNDROBIN; } else { + thobj->tslice = *quantum; xparam.sched_rr_quantum = *quantum; if (quantum->tv_sec == 0 && quantum->tv_nsec == 0) thobj->status &= ~THREADOBJ_ROUNDROBIN; @@ -634,7 +637,7 @@ static inline void set_rr(struct threadobj *thobj, struct timespec *quantum) { if (quantum) { thobj->status |= THREADOBJ_ROUNDROBIN; - thobj->core.tslice = *quantum; + thobj->tslice = *quantum; } else thobj->status &= ~THREADOBJ_ROUNDROBIN; } _______________________________________________ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git