Пример #1
0
static void sleep_tick_adjust(uint32_t ms)
{
	uint32_t diff;

	diff = rt_tick_from_millisecond(ms);

	rt_tick_set(rt_tick_get() + diff);
	{
		struct rt_thread *thread;

		/* check time slice */
		thread = rt_thread_self();

		if (thread->remaining_tick <= diff)
		{
			/* change to initialized tick */
			thread->remaining_tick = thread->init_tick;

			/* yield */
			rt_thread_yield();
		}
		else
		{
			thread->remaining_tick -= diff;
		}

		/* check timer */
		rt_timer_check();
	}
}
Пример #2
0
/**
 * This function will notify kernel there is one tick passed. Normally,
 * this function is invoked by clock ISR.
 */
void rt_tick_increase(void)
{
    struct rt_thread *thread;

    /* increase the global tick */
    ++ rt_tick;

    /* check time slice */
    thread = rt_thread_self();

    -- thread->remaining_tick;
    if (thread->remaining_tick == 0)
    {
        /* change to initialized tick */
        thread->remaining_tick = thread->init_tick;

        /* yield */
        rt_thread_yield();
    }

    /* check timer */
    rt_timer_check();
}