Exemplo n.º 1
0
void timer_interrupt(void)
{
	/* Increment processes and global tick counters. We can't do this
	   mid swap because we might have half of the bits for one process
	   and half of another.. */
	if (!inswap && udata.u_ptab->p_status == P_RUNNING) {
		if (udata.u_insys)
			udata.u_stime++;
		else
			udata.u_utime++;
	}

	/* Do once-per-decisecond things - this doesn't work out well on
	   boxes with 64 ticks/second.. need a better approach */
	if (++ticks_this_dsecond == ticks_per_dsecond) {
		static ptptr p;

		/* Update global time counters */
		ticks_this_dsecond = 0;
		ticks.full++;

		/* Update process alarm clocks and timeouts */
		for (p = ptab; p < ptab_end; ++p) {
			if (p->p_alarm) {
				p->p_alarm--;
				if (!p->p_alarm)
					ssig(p, SIGALRM);
			}
			if (p->p_timeout > 1) {
				p->p_timeout--;
				if (p->p_timeout == 1)
					pwake(p);
			}
		}
		updatetod();
                load_average();
#ifdef CONFIG_AUDIO
		audio_tick();
#endif
	}
#ifndef CONFIG_SINGLETASK
	/* Check run time of current process. We don't charge time while
	   swapping as the last thing we want to do is to swap a process in
	   and decide it took time to swap in so needs to go away again! */
	/* FIXME: can we kill off inint ? */
	if (!inswap && (++runticks >= udata.u_ptab->p_priority)
	    && !udata.u_insys && inint && nready > 1) {
                 need_resched = 1;
#ifdef DEBUG_PREEMPT
		kprintf("[preempt %p %d]", udata.u_ptab,
		        udata.u_ptab->p_priority);
#endif
        }
#endif
}
Exemplo n.º 2
0
void timer_interrupt(void)
{
	/* Increment processes and global tick counters */
	if (udata.u_ptab->p_status == P_RUNNING) {
		if (udata.u_insys)
			udata.u_stime++;
		else
			udata.u_utime++;
	}

	/* Do once-per-decisecond things - this doesn't work out well on
	   boxes with 64 ticks/second.. need a better approach */
	if (++ticks_this_dsecond == ticks_per_dsecond) {
		static ptptr p;

		/* Update global time counters */
		ticks_this_dsecond = 0;
		ticks.full++;

		/* Update process alarm clocks and timeouts */
		for (p = ptab; p < ptab_end; ++p) {
			if (p->p_alarm) {
				p->p_alarm--;
				if (!p->p_alarm)
					ssig(p, SIGALRM);
			}
			if (p->p_timeout > 1) {
				p->p_timeout--;
				if (p->p_timeout == 1)
					pwake(p);
			}
		}
		updatetod();
                load_average();
#ifdef CONFIG_AUDIO
		audio_tick();
#endif
	}
#ifndef CONFIG_SINGLETASK
	/* Check run time of current process */
        /* Time to switch out? */
	if ((++runticks >= udata.u_ptab->p_priority)
	    && !udata.u_insys && inint && nready > 1) {
                 need_resched = 1;
#ifdef DEBUG_PREEMPT
		kprintf("[preempt %x %d %x]", udata.u_ptab,
		        udata.u_ptab->p_priority,
		        *((uint16_t *)0xEAFE));
#endif
        }
#endif
}