📄 clock.c.svn-base
字号:
/* * File : clock.c * This file is part of RT-Thread RTOS * COPYRIGHT (C) 2006, RT-Thread Development Team * * The license and distribution terms for this file may be * found in the file LICENSE in this distribution or at * http://www.fayfayspace.org/license/LICENSE. * * Change Logs: * Date Author Notes * 2006-03-12 Bernard first version * 2006-05-27 Bernard add support for same priority thread schedule */#include <rtthread.h>static rt_tick_t rt_tick;static rt_time_t rt_passed_second;extern void rt_timer_check(void);/** * @addtogroup Kernel *//*@{*/void rt_system_tick_init(){ rt_tick = 0; rt_passed_second = 0;}/** * @brief get current tick from operating system startup * * this function will return current tick from operating system startup * * @return current tick */rt_tick_t rt_tick_get(){ /* return the global tick */ return rt_tick;}/** * @brief to increase one tick to kernel * * this function will notify there is one tick passed to kernel * */void rt_tick_increase(){ struct rt_thread* thread; /* increase the global tick */ ++ rt_tick; if (rt_tick % RT_TICK_PER_SECOND == 0) { ++rt_passed_second; } /* check timer */ rt_timer_check(); /* 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(); } else { rt_schedule(); }}/** * @brief get the tick from specified millisecond * * @param ms the specified millisecond * * this function will calculate the tick from millisecond * * @return the calculated tick */rt_tick_t rt_tick_from_millisecond(rt_uint32 ms){ /* return the calculated tick */ return RT_TICK_PER_SECOND * (ms / 1000);}/*@}*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -