void time_elapsed(struct sched_thd *t, u32_t processing_time)
{
	struct sched_accounting *sa;

	assert(t);
	sa = sched_get_accounting(t);
	sa->pol_cycles += processing_time;
	sa->cycles     += processing_time;
	if (sa->cycles >= QUANTUM) {
		while (sa->cycles > QUANTUM) {
			sa->cycles -= QUANTUM;
			sa->ticks++;
		}
		/* round robin */
		if (sched_thd_ready(t) && !sched_thd_suspended(t)) {
			assert(!sched_thd_inactive_evt(t));
			assert(!sched_thd_blocked(t));
			fp_move_end_runnable(t);
		}
#ifdef DEFERRABLE
#endif
	}
	if (sa->pol_cycles > QUANTUM) {
		sa->pol_cycles -= QUANTUM;
		if (sa->T) {
			sa->C_used++;
			if (sa->C_used >= sa->C) {
				sched_set_thd_urgency(t, NUM_PRIOS);
				if (sched_thd_ready(t)) fp_rem_thd(t);
				t->flags |= THD_SUSPENDED;
			}
		}
	}
}
static inline void fp_add_thd(struct sched_thd *t, unsigned short int prio)
{
	assert(prio < NUM_PRIOS);
	assert(sched_thd_ready(t));
	assert(!sched_thd_suspended(t));

	sched_get_metric(t)->priority = prio;
	sched_set_thd_urgency(t, prio);
	fp_move_end_runnable(t);

	return;
}
static inline void fp_add_thd(struct sched_thd *t, unsigned short int prio)
{
	assert(prio < NUM_PRIOS);
	assert(sched_thd_ready(t));
	assert(!sched_thd_suspended(t));

	sched_get_metric(t)->priority = prio;
	sched_set_thd_urgency(t, prio);
	/* printc("<< thread %d (prio %d) is added back to Q>>\n", t->id, prio); */
	fp_move_end_runnable(t);

	return;
}