Пример #1
0
static void timer_expire_entry(void * data,int cpu, double time, long long * number, const char **str)
{
	struct ftrace_so_timer * task =
		(struct ftrace_so_timer *)data;
	long long timer = number[FTRACE_SO_TIMER];
	timer_expire(task, cpu, time, timer);
}
int main (void)
{
	int msec;
	struct timer *timer;
	int randomvalue;
	int i;

printf ("adding timers\n");
	for (i = 0; i < 1000; i++) {
		timer = (struct timer *)malloc (sizeof (struct timer));
		randomvalue = random()%5000;
		timer->function = timer_function;
		timer->data = (void *)randomvalue;
		timer_add_msec_in_future (timer, randomvalue);
	}
printf ("done adding timers\n");

	for (;;) {
		msec = timer_expire_get_msec();
//		printf ("msec to next timer expire %d\n", msec);
		if (msec == -1) {
			printf ("no more timers\n");
			break;
		}
		poll (0, 0, msec);
		timer_expire ();
	}

	return (0);
}
Пример #3
0
void timer_intr(softvec_type_t type, unsigned long sp)
{
  if( timer_is_expired(0))
    {
      puts("timer expired 0. \n");
      timer_expire(0);
    }
  if( timer_is_expired(1))
    {
      puts("timer expired 1. \n");
      timer_cancel(1);
    }
}