/*
 * Cancel the timer 'tp'.  The timer object must have been initialized with
 * init_timer(3) first.  If the timer was not set before, the call is a no-op.
 */
void
cancel_timer(minix_timer_t * tp)
{
	clock_t next_time, prev_time;
	int r, have_timers;

	if (!tmr_is_set(tp))
		return;

	have_timers = tmrs_clrtimer(&timers, tp, &prev_time, &next_time);

	/*
	 * If the earliest timer has been removed, we have to set the alarm to
	 * the next timer, or cancel the alarm altogether if the last timer
	 * has been canceled.
	 */
        if (!expiring) {
		if (!have_timers)
			r = sys_setalarm(0, FALSE /*abs_time*/);
		else if (prev_time != next_time)
			r = sys_setalarm(next_time, TRUE /*abs_time*/);
		else
			r = OK;

		if (r != OK)
                        panic("cancel_timer: couldn't set alarm: %d", r);
        }
}
示例#2
0
/*===========================================================================*
 *                              cancel_timer                                 *
 *===========================================================================*/
void cancel_timer(timer_t *tp)
{
        clock_t next_time, prev_time;
        prev_time = tmrs_clrtimer(&timers, tp, &next_time);

        /* If the earliest timer has been removed, we have to set the alarm to
         * the next timer, or cancel the alarm altogether if the last timer
         * has been cancelled (next_time will be 0 then).
         */
        if (expiring == 0 && (prev_time < next_time || ! next_time)) {
                if (sys_setalarm(next_time, 1) != OK)
                        panic("cancel_timer: couldn't set alarm");
        }
}
示例#3
0
/*===========================================================================*
 *				pm_cancel_timer				     *
 *===========================================================================*/
PUBLIC void pm_cancel_timer(timer_t *tp)
{
	clock_t next_time, prev_time;
	prev_time = tmrs_clrtimer(&pm_timers, tp, &next_time);

	/* If the earliest timer has been removed, we have to set the alarm to  
     * the next timer, or cancel the alarm altogether if the last timer has 
     * been cancelled (next_time will be 0 then).
	 */
	if (prev_time < next_time || ! next_time) {
		if (sys_setalarm(next_time, 1) != OK)
			panic(__FILE__, "PM expire timer couldn't set alarm.", NO_NUM);
	}
}