Module: xenomai-forge Branch: next Commit: 109dbf443179325c452c403e84fc932343c17eaf URL: http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=109dbf443179325c452c403e84fc932343c17eaf
Author: Philippe Gerum <r...@xenomai.org> Date: Wed May 8 18:48:58 2013 +0200 copperplate/threadobj: threadobj_wait_period() implicitly applies to current --- include/copperplate/threadobj.h | 3 +-- lib/alchemy/task.c | 2 +- lib/copperplate/threadobj.c | 18 +++++++----------- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/include/copperplate/threadobj.h b/include/copperplate/threadobj.h index ac8d846..609826b 100644 --- a/include/copperplate/threadobj.h +++ b/include/copperplate/threadobj.h @@ -308,8 +308,7 @@ int threadobj_set_rr(struct threadobj *thobj, struct timespec *quantum); int threadobj_set_periodic(struct threadobj *thobj, struct timespec *idate, struct timespec *period); -int threadobj_wait_period(struct threadobj *thobj, - unsigned long *overruns_r); +int threadobj_wait_period(unsigned long *overruns_r); void threadobj_spin(ticks_t ns); diff --git a/lib/alchemy/task.c b/lib/alchemy/task.c index 9c59f38..1103cb8 100644 --- a/lib/alchemy/task.c +++ b/lib/alchemy/task.c @@ -812,7 +812,7 @@ int rt_task_wait_period(unsigned long *overruns_r) if (tcb == NULL) return -EPERM; - return threadobj_wait_period(&tcb->thobj, overruns_r); + return threadobj_wait_period(overruns_r); } /** diff --git a/lib/copperplate/threadobj.c b/lib/copperplate/threadobj.c index 93373f4..bacdf5f 100644 --- a/lib/copperplate/threadobj.c +++ b/lib/copperplate/threadobj.c @@ -307,10 +307,8 @@ int threadobj_set_periodic(struct threadobj *thobj, CLOCK_COPPERPLATE, idate, period); } -int threadobj_wait_period(struct threadobj *thobj, - unsigned long *overruns_r) +int threadobj_wait_period(unsigned long *overruns_r) { - assert(thobj == threadobj_current()); return -pthread_wait_np(overruns_r); } @@ -667,21 +665,19 @@ int threadobj_set_periodic(struct threadobj *thobj, return 0; } -int threadobj_wait_period(struct threadobj *thobj, - unsigned long *overruns_r) +int threadobj_wait_period(unsigned long *overruns_r) { + struct threadobj *current = threadobj_current(); struct timespec now, delta, wakeup; unsigned long overruns = 0; ticks_t d, period; int ret; - assert(thobj == threadobj_current()); - - period = thobj->core.period; + period = current->core.period; if (period == 0) return -EWOULDBLOCK; - wakeup = thobj->core.wakeup; + wakeup = current->core.wakeup; ret = threadobj_sleep(&wakeup); if (ret) return ret; @@ -694,10 +690,10 @@ int threadobj_wait_period(struct threadobj *thobj, d = timespec_scalar(&delta); if (d >= period) { overruns = d / period; - timespec_adds(&thobj->core.wakeup, &wakeup, + timespec_adds(¤t->core.wakeup, &wakeup, overruns * (period + 1)); } else - timespec_adds(&thobj->core.wakeup, &wakeup, period); + timespec_adds(¤t->core.wakeup, &wakeup, period); if (overruns) ret = -ETIMEDOUT; _______________________________________________ Xenomai-git mailing list Xenomai-git@xenomai.org http://www.xenomai.org/mailman/listinfo/xenomai-git