xref: /minix/minix/lib/libtimers/tmrs_exp.c (revision 00e393ca)
1 #include <minix/timers.h>
2 
3 /*
4  * Use the current time to check the timers queue list for expired timers.
5  * Run the watchdog functions for all expired timers and deactivate them.
6  * The caller is responsible for scheduling a new alarm if needed.
7  */
8 int
9 tmrs_exptimers(minix_timer_t ** tmrs, clock_t now, clock_t * new_head)
10 {
11 	minix_timer_t *tp;
12 	tmr_func_t func;
13 
14 	while ((tp = *tmrs) != NULL && tmr_has_expired(tp, now)) {
15 		*tmrs = tp->tmr_next;
16 
17 		func = tp->tmr_func;
18 		tp->tmr_func = NULL;
19 
20 		(*func)(tp->tmr_arg);
21 	}
22 
23 	if (*tmrs != NULL) {
24 		if (new_head != NULL)
25 			*new_head = (*tmrs)->tmr_exp_time;
26 		return TRUE;
27 	} else
28 		return FALSE;
29 }
30