From 2cd74d043db950dbc63e5b97603359584970a907 Mon Sep 17 00:00:00 2001 From: Valentin Sawadski Date: Mon, 10 Nov 2014 17:21:18 +0100 Subject: [PATCH] CTIMER API extension to explictly state the process a ctimer belongs to --- core/sys/ctimer.c | 9 ++++++++- core/sys/ctimer.h | 18 ++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/core/sys/ctimer.c b/core/sys/ctimer.c index c72f247f5..66698a8e6 100644 --- a/core/sys/ctimer.c +++ b/core/sys/ctimer.c @@ -98,9 +98,16 @@ ctimer_init(void) void ctimer_set(struct ctimer *c, clock_time_t t, void (*f)(void *), void *ptr) +{ + ctimer_set_with_process(c, t, f, ptr, PROCESS_CURRENT()); +} +/*---------------------------------------------------------------------------*/ +void +ctimer_set_with_process(struct ctimer *c, clock_time_t t, + void (*f)(void *), void *ptr, struct process *p) { PRINTF("ctimer_set %p %u\n", c, (unsigned)t); - c->p = PROCESS_CURRENT(); + c->p = p; c->f = f; c->ptr = ptr; if(initialized) { diff --git a/core/sys/ctimer.h b/core/sys/ctimer.h index bebe8a532..dabf43d8a 100644 --- a/core/sys/ctimer.h +++ b/core/sys/ctimer.h @@ -109,10 +109,28 @@ void ctimer_restart(struct ctimer *c); * sometime in the future. When the callback timer expires, * the callback function f will be called with ptr as argument. * + * This essentially does ctimer_set_process(c, t, f, ptr, PROCESS_CURRENT()); + * */ void ctimer_set(struct ctimer *c, clock_time_t t, void (*f)(void *), void *ptr); +/** + * \brief Set a callback timer. + * \param c A pointer to the callback timer. + * \param t The interval before the timer expires. + * \param f A function to be called when the timer expires. + * \param ptr An opaque pointer that will be supplied as an argument to the callback function. + * \param p A pointer to the process the timer belongs to + * + * This function is used to set a callback timer for a time + * sometime in the future. When the callback timer expires, + * the callback function f will be called with ptr as argument. + * + */ +void ctimer_set_with_process(struct ctimer *c, clock_time_t t, + void (*f)(void *), void *ptr, struct process *p); + /** * \brief Stop a pending callback timer. * \param c A pointer to the pending callback timer.