void vtimer_tick(void *ptr) { DEBUG("vtimer_tick()."); seconds += SECONDS_PER_TICK; longterm_tick_start = longterm_tick_timer.absolute.microseconds; longterm_tick_timer.absolute.microseconds = longterm_tick_timer.absolute.microseconds + MICROSECONDS_PER_TICK; set_shortterm(&longterm_tick_timer); while (longterm_queue_root.next) { vtimer_t *timer = (vtimer_t*) longterm_queue_root.next; if (timer->absolute.seconds == seconds) { timer = (vtimer_t*) queue_remove_head(&longterm_queue_root); set_shortterm(timer); } else { break; } } update_shortterm(); }
void vtimer_callback_tick(vtimer_t *timer) { (void) timer; DEBUG("vtimer_callback_tick().\n"); longterm_tick_start += MICROSECONDS_PER_TICK; longterm_tick_timer.absolute.seconds += SECONDS_PER_TICK; longterm_tick_timer.absolute.microseconds = MICROSECONDS_PER_TICK; // Should never change, just for clarity. set_shortterm(&longterm_tick_timer); while (longterm_priority_queue_root.first) { vtimer_t *timer = node_get_timer(longterm_priority_queue_root.first); if (timer->absolute.seconds == longterm_tick_timer.absolute.seconds) { priority_queue_remove_head(&longterm_priority_queue_root); set_shortterm(timer); } else { break; } } }
void vtimer_callback_tick(vtimer_t *timer) { (void) timer; DEBUG("vtimer_callback_tick().\n"); seconds += SECONDS_PER_TICK; longterm_tick_start = longterm_tick_timer.absolute.microseconds; longterm_tick_timer.absolute.microseconds += MICROSECONDS_PER_TICK; set_shortterm(&longterm_tick_timer); while (longterm_queue_root.first) { vtimer_t *timer = (vtimer_t *) longterm_queue_root.first; if (timer->absolute.seconds == seconds) { queue_remove_head(&longterm_queue_root); set_shortterm(timer); } else { break; } } }
int vtimer_init() { DEBUG("vtimer_init().\n"); int state = disableIRQ(); seconds = 0; longterm_tick_timer.action = vtimer_tick; longterm_tick_timer.arg = NULL; longterm_tick_timer.absolute.seconds = 0; longterm_tick_timer.absolute.microseconds = MICROSECONDS_PER_TICK; DEBUG("vtimer_init(): Setting longterm tick to %lu\n", longterm_tick_timer.absolute.microseconds); set_shortterm(&longterm_tick_timer); update_shortterm(); restoreIRQ(state); return 0; }
static int vtimer_set(vtimer_t *timer) { DEBUG("vtimer_set(): New timer. Offset: %" PRIu32 " %" PRIu32 "\n", timer->absolute.seconds, timer->absolute.microseconds); timex_t now; vtimer_now(&now); timer->absolute = timex_add(now, timer->absolute); normalize_to_tick(&(timer->absolute)); DEBUG("vtimer_set(): Absolute: %" PRIu32 " %" PRIu32 "\n", timer->absolute.seconds, timer->absolute.microseconds); DEBUG("vtimer_set(): NOW: %" PRIu32 " %" PRIu32 "\n", now.seconds, now.microseconds); int result = 0; if (timer->absolute.seconds == 0) { if (timer->absolute.microseconds > 10) { timer->absolute.microseconds -= 10; } } unsigned state = disableIRQ(); if (timer->absolute.seconds != longterm_tick_timer.absolute.seconds) { /* we're long-term */ DEBUG("vtimer_set(): setting long_term\n"); result = set_longterm(timer); } else { DEBUG("vtimer_set(): setting short_term\n"); if (set_shortterm(timer)) { /* delay update of next shortterm timer if we * are called from within vtimer_callback. */ if (!in_callback) { result = update_shortterm(); } } } restoreIRQ(state); return result; }
void vtimer_init(void) { DEBUG("vtimer_init().\n"); unsigned state = disableIRQ(); longterm_tick_start = 0; longterm_tick_timer.action = vtimer_callback_tick; longterm_tick_timer.arg = NULL; longterm_tick_timer.absolute.seconds = 0; longterm_tick_timer.absolute.microseconds = MICROSECONDS_PER_TICK; DEBUG("vtimer_init(): Setting longterm tick to %" PRIu32 "\n", longterm_tick_timer.absolute.microseconds); set_shortterm(&longterm_tick_timer); update_shortterm(); restoreIRQ(state); }