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