高精度定时器在mips上的框架结构
2012-09-03 09:43
176 查看
大体流程:
run_timer_softirq
hrtimer_run_pending
hrtimer_switch_to_hres
tick_setup_sched_timer
hrtimer_init/*settup hr tick timer,tick-sched.c*/
tick_sched_timer /*hard irq context*/
plat_irq_dispatch
nlm_common_timer_interrupt
do_IRQ
desc->handle_irq
c0_compare_interrupt
struct clock_event_device *cd;
cd = &per_cpu(mips_clockevent_device, cpu);
cd->event_handler(cd);
cd->event_handler
hrtimer_interrupt
tick_sched_timer
update_process_times
run_local_timers
hrtimer_run_queues (当前tick timer已被摘除,不在queue中,因此将自己再次加入红黑树并触发下一次时钟)
32内核的高精度定时运行环境是在硬中断下
1)系统刚初始化时,clock_device dev的 event_handler是一个空函数,后面被替换成tick_handle_periodic,
tick_check_new_device--->
tick_setup_device--->
tick_setup_periodic-->
tick_set_periodic_handler--->
dev->event_handler = tick_handle_periodic;
接着主动触发一个时钟中断
clockevents_program_event---> dev->set_next_event 操作compare寄存器来触发
2)timer_interrupt-->event_handler-->tick_handle_periodic---> tick_periodic--->
update_process_times--->run_local_timers--->raise_softirq(TIMER_SOFTIRQ);
详细的流程(plat_irq_dispatch
nlm_common_timer_interrupt
do_IRQ
desc->handle_irq
c0_compare_interrupt
struct clock_event_device *cd;
cd = &per_cpu(mips_clockevent_device, cpu);
cd->event_handler(cd);
cd->event_handler
)
3)软中断里,每次都在hrtimer_run_pending尝试进行高精度时钟切换,如果切换不成功,即没有
配置高精度定时器,则在run_timer_softirq里走timer wheel定时器。
static void run_timer_softirq(struct softirq_action *h)
{
struct tvec_base *base = __get_cpu_var(tvec_bases);
perf_event_do_pending();
hrtimer_run_pending();
if (time_after_eq(jiffies, base->timer_jiffies))
__run_timers(base);
}
run_timer_softirq-->hrtimer_run_pending--->hrtimer_switch_to_hres-->event_handler = hrtimer_interrupt;
event_handler被换成hrtimer_interrupt
This _is_ ugly: We have to check in the softirq context,
whether we can switch to highres and / or nohz mode.
if (tick_check_oneshot_change(!hrtimer_is_hres_enabled()))
hrtimer_switch_to_hres();
hrtimer_switch_to_hres-->tick_init_highres-->tick_switch_to_oneshot(hrtimer_interrupt);-->dev->event_handler = handler;
4)然后就是高精度定时器处理流程了
timer_interrupt-->event_handler--->hrtimer_interrupt-->
在高精度时钟切换完毕后,会有一个尝试启动周期定时器即系统心跳的操作。
tick_setup_sched_timer
如果系统没有高精度时钟支持(即没有count compare), 则在低精度模式下如何运作?
运行流程是什么?
run_timer_softirq
hrtimer_run_pending
hrtimer_switch_to_hres
tick_setup_sched_timer
hrtimer_init/*settup hr tick timer,tick-sched.c*/
tick_sched_timer /*hard irq context*/
plat_irq_dispatch
nlm_common_timer_interrupt
do_IRQ
desc->handle_irq
c0_compare_interrupt
struct clock_event_device *cd;
cd = &per_cpu(mips_clockevent_device, cpu);
cd->event_handler(cd);
cd->event_handler
hrtimer_interrupt
tick_sched_timer
update_process_times
run_local_timers
hrtimer_run_queues (当前tick timer已被摘除,不在queue中,因此将自己再次加入红黑树并触发下一次时钟)
32内核的高精度定时运行环境是在硬中断下
1)系统刚初始化时,clock_device dev的 event_handler是一个空函数,后面被替换成tick_handle_periodic,
tick_check_new_device--->
tick_setup_device--->
tick_setup_periodic-->
tick_set_periodic_handler--->
dev->event_handler = tick_handle_periodic;
接着主动触发一个时钟中断
clockevents_program_event---> dev->set_next_event 操作compare寄存器来触发
2)timer_interrupt-->event_handler-->tick_handle_periodic---> tick_periodic--->
update_process_times--->run_local_timers--->raise_softirq(TIMER_SOFTIRQ);
详细的流程(plat_irq_dispatch
nlm_common_timer_interrupt
do_IRQ
desc->handle_irq
c0_compare_interrupt
struct clock_event_device *cd;
cd = &per_cpu(mips_clockevent_device, cpu);
cd->event_handler(cd);
cd->event_handler
)
3)软中断里,每次都在hrtimer_run_pending尝试进行高精度时钟切换,如果切换不成功,即没有
配置高精度定时器,则在run_timer_softirq里走timer wheel定时器。
static void run_timer_softirq(struct softirq_action *h)
{
struct tvec_base *base = __get_cpu_var(tvec_bases);
perf_event_do_pending();
hrtimer_run_pending();
if (time_after_eq(jiffies, base->timer_jiffies))
__run_timers(base);
}
run_timer_softirq-->hrtimer_run_pending--->hrtimer_switch_to_hres-->event_handler = hrtimer_interrupt;
event_handler被换成hrtimer_interrupt
This _is_ ugly: We have to check in the softirq context,
whether we can switch to highres and / or nohz mode.
if (tick_check_oneshot_change(!hrtimer_is_hres_enabled()))
hrtimer_switch_to_hres();
hrtimer_switch_to_hres-->tick_init_highres-->tick_switch_to_oneshot(hrtimer_interrupt);-->dev->event_handler = handler;
4)然后就是高精度定时器处理流程了
timer_interrupt-->event_handler--->hrtimer_interrupt-->
在高精度时钟切换完毕后,会有一个尝试启动周期定时器即系统心跳的操作。
tick_setup_sched_timer
如果系统没有高精度时钟支持(即没有count compare), 则在低精度模式下如何运作?
运行流程是什么?
相关文章推荐
- 高精度定时器在mips上的框架结构
- 框架开发教程(三):基本结构
- Spry Framework入门(三)——框架结构
- 使用Butter Knife 框架时报NullPointerException(Android studio或者IntelliJ IEDA开发,eclipse结构工程)
- spring MVC 框架结构和过程
- C#写一个高精度定时器
- Feistel网络结构与DES加密算法的框架简单分析
- iOS开发UI篇—QQ主流UI框架结构
- UI进阶--APP主流UI框架结构
- tx4-封装运动框架多属性函数-定时器-透明度-zIndex
- Windows Driver Foundation - KMDF 内核模式驱动框架结构 第二部分
- web开发 HTML/CSS基本框架结构讲解
- CppUnit中测试框架的核心组件类图结构
- Ffmpeg框架结构解读 .
- vue项目框架结构入门 及 vue基础
- kbe定时器框架
- 对于SWE发问__框架结构
- android 快速开发框架,基于组件化的MVP结构
- Linux时间子系统之六:高精度定时器(HRTIMER)的原理和实现