bool test_alarm(void) { const int INTERVAL = 10000; const int ITERATIONS = 100; void alarm_handler(struct alarm_waiter *waiter) { __sync_fetch_and_add((int*)waiter->data, 1); set_awaiter_inc(waiter, INTERVAL); set_alarm(waiter); }
/* RKM alarm, to run the scheduler tick (not in interrupt context) and reset the * alarm. Note that interrupts will be disabled, but this is not the same as * interrupt context. We're a routine kmsg, which means the core is in a * quiescent state. */ static void __ksched_tick(struct alarm_waiter *waiter) { /* TODO: imagine doing some accounting here */ run_scheduler(); /* Set our alarm to go off, incrementing from our last tick (instead of * setting it relative to now, since some time has passed since the alarm * first went off. Note, this may be now or in the past! */ set_awaiter_inc(&ksched_waiter, TIMER_TICK_USEC); set_alarm(&per_cpu_info[core_id()].tchain, &ksched_waiter); }