Esempio n. 1
0
/*===========================================================================*
 *				pm_expire_timers			     *
 *===========================================================================*/
PUBLIC void pm_expire_timers(clock_t now)
{
	clock_t next_time;

	/* Check for expired timers and possibly reschedule an alarm. */
	tmrs_exptimers(&pm_timers, now, &next_time);
	if (next_time > 0) {
		if (sys_setalarm(next_time, 1) != OK)
			panic(__FILE__, "PM expire timer couldn't set alarm.", NO_NUM);
	}
}
Esempio n. 2
0
/*===========================================================================*
 *                              expire_timers                                *
 *===========================================================================*/
void expire_timers(clock_t now)
{
        clock_t next_time;

        /* Check for expired timers. Use a global variable to indicate that
         * watchdog functions are called, so that sys_setalarm() isn't called
         * more often than necessary when set_timer or cancel_timer are called
         * from these watchdog functions. */
        expiring = 1;
        tmrs_exptimers(&timers, now, &next_time);
        expiring = 0;

        /* Reschedule an alarm if necessary. */
        if (next_time > 0) {
                if (sys_setalarm(next_time, 1) != OK)
                        panic("expire_timers: couldn't set alarm");
        }
}
/*
 * Expire all timers that were set to expire before/at the given current time.
 */
void
expire_timers(clock_t now)
{
        clock_t next_time;
	int r, have_timers;

	/*
	 * Check for expired timers. Use a global variable to indicate that
	 * watchdog functions are called, so that sys_setalarm() isn't called
	 * more often than necessary when set_timer or cancel_timer are called
	 * from these watchdog functions.
	 */
	expiring = TRUE;
	have_timers = tmrs_exptimers(&timers, now, &next_time);
	expiring = FALSE;

	/* Reschedule an alarm if necessary. */
	if (have_timers) {
		if ((r = sys_setalarm(next_time, TRUE /*abs_time*/)) != OK)
			panic("expire_timers: couldn't set alarm: %d", r);
	}
}
Esempio n. 4
0
/*
 * The boot processos timer interrupt handler. In addition to non-boot cpus it
 * keeps real time and notifies the clock task if need be
 */
PUBLIC int timer_int_handler(void)
{
	/* Update user and system accounting times. Charge the current process
	 * for user time. If the current process is not billable, that is, if a
	 * non-user process is running, charge the billable process for system
	 * time as well.  Thus the unbillable process' user time is the billable
	 * user's system time.
	 */

	struct proc * p, * billp;

	/* FIXME watchdog for slave cpus! */
#ifdef CONFIG_WATCHDOG
	/*
	 * we need to know whether local timer ticks are happening or whether
	 * the kernel is locked up. We don't care about overflows as we only
	 * need to know that it's still ticking or not
	 */
	watchdog_local_timer_ticks++;
#endif

	if (cpu_is_bsp(cpuid))
		realtime++;

	/* Update user and system accounting times. Charge the current process
	 * for user time. If the current process is not billable, that is, if a
	 * non-user process is running, charge the billable process for system
	 * time as well.  Thus the unbillable process' user time is the billable
	 * user's system time.
	 */

	p = get_cpulocal_var(proc_ptr);
	billp = get_cpulocal_var(bill_ptr);

	p->p_user_time++;

	if (! (priv(p)->s_flags & BILLABLE)) {
		billp->p_sys_time++;
	}

	/* Decrement virtual timers, if applicable. We decrement both the
	 * virtual and the profile timer of the current process, and if the
	 * current process is not billable, the timer of the billed process as
	 * well.  If any of the timers expire, do_clocktick() will send out
	 * signals.
	 */
	if ((p->p_misc_flags & MF_VIRT_TIMER)){
		p->p_virt_left--;
	}
	if ((p->p_misc_flags & MF_PROF_TIMER)){
		p->p_prof_left--;
	}
	if (! (priv(p)->s_flags & BILLABLE) &&
			(billp->p_misc_flags & MF_PROF_TIMER)){
		billp->p_prof_left--;
	}

	/*
	 * Check if a process-virtual timer expired. Check current process, but
	 * also bill_ptr - one process's user time is another's system time, and
	 * the profile timer decreases for both!
	 */
	vtimer_check(p);

	if (p != billp)
		vtimer_check(billp);

	/* Update load average. */
	load_update();

	if (cpu_is_bsp(cpuid)) {
		/* if a timer expired, notify the clock task */
		if ((next_timeout <= realtime)) {
			tmrs_exptimers(&clock_timers, realtime, NULL);
			next_timeout = (clock_timers == NULL) ?
				TMR_NEVER : clock_timers->tmr_exp_time;
		}

		if (do_serial_debug)
			do_ser_debug();
	}

	return(1);					/* reenable interrupts */
}