void xntimer_switch_tracking(struct xntimer *timer, struct xnclock *newclock) { struct xnclock *oldclock = timer->tracker; spl_t s; xnlock_get_irqsave(&nklock, s); list_del(&timer->next_stat); oldclock->nrtimers--; xnvfile_touch(&oldclock->timer_vfile); list_add_tail(&timer->next_stat, &newclock->timerq); newclock->nrtimers++; xnvfile_touch(&newclock->timer_vfile); timer->tracker = newclock; xnlock_put_irqrestore(&nklock, s); }
void xntimer_destroy(xntimer_t *timer) { spl_t s; xnlock_get_irqsave(&nklock, s); xntimer_stop(timer); __setbits(timer->status, XNTIMER_KILLED); timer->sched = NULL; #ifdef CONFIG_XENO_OPT_STATS removeq(&xntimer_base(timer)->timerq, &timer->tblink); xnvfile_touch(&xntimer_base(timer)->vfile); #endif /* CONFIG_XENO_OPT_TIMING_PERIODIC */ xnlock_put_irqrestore(&nklock, s); }
void __xntimer_init(struct xntimer *timer, struct xnclock *clock, void (*handler)(struct xntimer *timer), struct xnsched *sched, int flags) { spl_t s __maybe_unused; int cpu; #ifdef CONFIG_XENO_OPT_EXTCLOCK timer->clock = clock; #endif xntimerh_init(&timer->aplink); xntimerh_date(&timer->aplink) = XN_INFINITE; xntimer_set_priority(timer, XNTIMER_STDPRIO); timer->status = (XNTIMER_DEQUEUED|(flags & XNTIMER_INIT_MASK)); timer->handler = handler; timer->interval_ns = 0; /* * Timers are affine to a scheduler slot, which is in turn * bound to a real-time CPU. If no scheduler affinity was * given, assign the timer to the scheduler slot of the * current CPU if real-time, otherwise default to the * scheduler slot of the first real-time CPU. */ if (sched) timer->sched = sched; else { cpu = ipipe_processor_id(); if (!xnsched_supported_cpu(cpu)) cpu = first_cpu(xnsched_realtime_cpus); timer->sched = xnsched_struct(cpu); } #ifdef CONFIG_XENO_OPT_STATS #ifdef CONFIG_XENO_OPT_EXTCLOCK timer->tracker = clock; #endif ksformat(timer->name, XNOBJECT_NAME_LEN, "%d/%s", current->pid, current->comm); xntimer_reset_stats(timer); xnlock_get_irqsave(&nklock, s); list_add_tail(&timer->next_stat, &clock->timerq); clock->nrtimers++; xnvfile_touch(&clock->timer_vfile); xnlock_put_irqrestore(&nklock, s); #endif /* CONFIG_XENO_OPT_STATS */ }
/** * @fn void xntimer_destroy(struct xntimer *timer) * * @brief Release a timer object. * * Destroys a timer. After it has been destroyed, all resources * associated with the timer have been released. The timer is * automatically deactivated before deletion if active on entry. * * @param timer The address of a valid timer descriptor. * * @coretags{unrestricted} */ void xntimer_destroy(struct xntimer *timer) { struct xnclock *clock __maybe_unused = xntimer_clock(timer); spl_t s; xnlock_get_irqsave(&nklock, s); xntimer_stop(timer); timer->status |= XNTIMER_KILLED; timer->sched = NULL; #ifdef CONFIG_XENO_OPT_STATS list_del(&timer->next_stat); clock->nrtimers--; xnvfile_touch(&clock->timer_vfile); #endif /* CONFIG_XENO_OPT_STATS */ xnlock_put_irqrestore(&nklock, s); }
void __xntimer_init(xntimer_t *timer, xntbase_t *base, void (*handler) (xntimer_t *timer)) { /* CAUTION: Setup from xntimer_init() must not depend on the periodic/aperiodic timing mode. */ xntimerh_init(&timer->aplink); xntimerh_date(&timer->aplink) = XN_INFINITE; #ifdef CONFIG_XENO_OPT_TIMING_PERIODIC timer->base = base; xntlholder_init(&timer->plink); xntlholder_date(&timer->plink) = XN_INFINITE; #endif /* CONFIG_XENO_OPT_TIMING_PERIODIC */ xntimer_set_priority(timer, XNTIMER_STDPRIO); timer->status = XNTIMER_DEQUEUED; timer->handler = handler; timer->interval = 0; timer->sched = xnpod_current_sched(); #ifdef CONFIG_XENO_OPT_STATS { spl_t s; if (!xnpod_current_thread() || xnpod_shadow_p()) snprintf(timer->name, XNOBJECT_NAME_LEN, "%d/%s", current->pid, current->comm); else xnobject_copy_name(timer->name, xnpod_current_thread()->name); inith(&timer->tblink); xnstat_counter_set(&timer->scheduled, 0); xnstat_counter_set(&timer->fired, 0); xnlock_get_irqsave(&nklock, s); appendq(&base->timerq, &timer->tblink); xnvfile_touch(&base->vfile); xnlock_put_irqrestore(&nklock, s); } #endif /* CONFIG_XENO_OPT_STATS */ xnarch_init_display_context(timer); }