3 /*===========================================================================*
5 *===========================================================================*/
6 clock_t tmrs_settimer(tmrs
, tp
, exp_time
, watchdog
, new_head
)
7 timer_t
**tmrs
; /* pointer to timers queue */
8 timer_t
*tp
; /* the timer to be added */
9 clock_t exp_time
; /* its expiration time */
10 tmr_func_t watchdog
; /* watchdog function to be run */
11 clock_t *new_head
; /* new earliest timer, if non NULL */
13 /* Activate a timer to run function 'fp' at time 'exp_time'. If the timer is
14 * already in use it is first removed from the timers queue. Then, it is put
15 * in the list of active timers with the first to expire in front.
16 * The caller responsible for scheduling a new alarm for the timer if needed.
22 old_head
= (*tmrs
)->tmr_exp_time
;
24 /* Set the timer's variables. */
25 (void) tmrs_clrtimer(tmrs
, tp
, NULL
);
26 tp
->tmr_exp_time
= exp_time
;
27 tp
->tmr_func
= watchdog
;
29 /* Add the timer to the active timers. The next timer due is in front. */
30 for (atp
= tmrs
; *atp
!= NULL
; atp
= &(*atp
)->tmr_next
) {
31 if (exp_time
< (*atp
)->tmr_exp_time
) break;
36 (*new_head
) = (*tmrs
)->tmr_exp_time
;