• timer event


    /* linux/kernel/time/jiffies.c*/
    static cycle_t jiffies_read(struct clocksource *cs)
    {
        return (cycle_t) jiffies;
    }
    
    struct clocksource clocksource_jiffies = {
        .name        = "jiffies",
        .rating        = 1, /* lowest valid rating*/
        .read        = jiffies_read,
        .mask        = 0xffffffff, /*32bits*/
        .mult        = NSEC_PER_JIFFY << JIFFIES_SHIFT, /* details above */
        .mult_orig    = NSEC_PER_JIFFY << JIFFIES_SHIFT,
        .shift        = JIFFIES_SHIFT,
    };
    
    static int __init init_jiffies_clocksource(void)
    {
        return clocksource_register(&clocksource_jiffies);
    }
    
    core_initcall(init_jiffies_clocksource);
    
    
    int clocksource_register(struct clocksource *c)
        -->ret = clocksource_enqueue(c);
        /*静态全局变量存储下一个精度最高的时钟源
        static struct clocksource *next_clocksource;*/
        -->next_clocksource = select_clocksource();
    
    struct clocksource *clocksource_get_next(void)
        /*静态全局变量存储当前使用的时钟源
        static struct clocksource *curr_clocksource = &clocksource_jiffies;*/
        -->curr_clocksource = next_clocksource;
    
    /*什么时间更换时钟源,以下两种方法选择其一*/
    /*1.jiffies时间中断处理函数*/
    static irqreturn_t s3c2410_timer_interrupt(int irq, void *dev_id)
        -->void timer_tick(void)
            -->void do_timer(unsigned long ticks)
                -->jiffies_64 += ticks;
                -->update_times(ticks);
                    -->void update_wall_time(void)
                        /* check to see if there is a new clocksource to use */
                        -->change_clocksource();
    /*2.jiffies时间中断处理函数*/
    void clockevents_register_device(struct clock_event_device *dev)
        /*内核通知链触发*/
        -->clockevents_do_notify(CLOCK_EVT_NOTIFY_ADD, dev);
    
    /*通知链注册*/
    void __init tick_init(void)
        /*static struct notifier_block tick_notifier = {
        .notifier_call = tick_notify,
        };*/
        -->clockevents_register_notifier(&tick_notifier);
    /*通知链回调*/    
    static int tick_notify(struct notifier_block *nb, unsigned long reason,void *dev)
        -->static int tick_check_new_device(struct clock_event_device *newdev)
            -->static void tick_setup_device(struct tick_device *td,struct clock_event_device *newdev, int cpu,const struct cpumask *cpumask)
                -->void tick_setup_periodic(struct clock_event_device *dev, int broadcast)
                    -->void tick_set_periodic_handler(struct clock_event_device *dev, int broadcast)
                        -->dev->event_handler = tick_handle_periodic;
    /*event时间处理函数调用*/
    void tick_handle_periodic(struct clock_event_device *dev)
        -->static void tick_periodic(int cpu)
            -->void do_timer(unsigned long ticks)
                -->jiffies_64 += ticks;
                -->update_times(ticks);
                    -->void update_wall_time(void)
                        /* check to see if there is a new clocksource to use */
                        -->change_clocksource();

    /* linux/kernel/time/jiffies.c*/static cycle_t jiffies_read(struct clocksource *cs){return (cycle_t) jiffies;}
    struct clocksource clocksource_jiffies = {.name= "jiffies",.rating= 1, /* lowest valid rating*/.read= jiffies_read,.mask= 0xffffffff, /*32bits*/.mult= NSEC_PER_JIFFY << JIFFIES_SHIFT, /* details above */.mult_orig= NSEC_PER_JIFFY << JIFFIES_SHIFT,.shift= JIFFIES_SHIFT,};
    static int __init init_jiffies_clocksource(void){return clocksource_register(&clocksource_jiffies);}
    core_initcall(init_jiffies_clocksource);

    int clocksource_register(struct clocksource *c)-->ret = clocksource_enqueue(c);/*静态全局变量存储下一个精度最高的时钟源static struct clocksource *next_clocksource;*/-->next_clocksource = select_clocksource();
    struct clocksource *clocksource_get_next(void)/*静态全局变量存储当前使用的时钟源static struct clocksource *curr_clocksource = &clocksource_jiffies;*/-->curr_clocksource = next_clocksource;
    /*什么时间更换时钟源,以下两种方法选择其一*//*1.jiffies时间中断处理函数*/static irqreturn_t s3c2410_timer_interrupt(int irq, void *dev_id)-->void timer_tick(void)-->void do_timer(unsigned long ticks)-->jiffies_64 += ticks;-->update_times(ticks);-->void update_wall_time(void)/* check to see if there is a new clocksource to use */-->change_clocksource();/*2.jiffies时间中断处理函数*/void clockevents_register_device(struct clock_event_device *dev)/*内核通知链触发*/-->clockevents_do_notify(CLOCK_EVT_NOTIFY_ADD, dev);
    /*通知链注册*/void __init tick_init(void)/*static struct notifier_block tick_notifier = {.notifier_call = tick_notify,};*/-->clockevents_register_notifier(&tick_notifier);/*通知链回调*/static int tick_notify(struct notifier_block *nb, unsigned long reason,void *dev)-->static int tick_check_new_device(struct clock_event_device *newdev)-->static void tick_setup_device(struct tick_device *td,struct clock_event_device *newdev, int cpu,const struct cpumask *cpumask)-->void tick_setup_periodic(struct clock_event_device *dev, int broadcast)-->void tick_set_periodic_handler(struct clock_event_device *dev, int broadcast)-->dev->event_handler = tick_handle_periodic;/*event时间处理函数调用*/void tick_handle_periodic(struct clock_event_device *dev)-->static void tick_periodic(int cpu)-->void do_timer(unsigned long ticks)-->jiffies_64 += ticks;-->update_times(ticks);-->void update_wall_time(void)/* check to see if there is a new clocksource to use */-->change_clocksource();

  • 相关阅读:
    LostRoutes项目日志——玩家飞机精灵Fighter解析
    quartz Cron表达式一分钟教程
    vue-cli入门
    SQL中merge into用法
    SQLSERVER查询那个表里有数据
    C#实现复杂XML的序列化与反序列化
    MVC和WebApi 使用get和post 传递参数。
    项目管理软件推荐
    JS跨域请求
    Android动画效果translate、scale、alpha、rotate详解
  • 原文地址:https://www.cnblogs.com/yangjiguang/p/8329126.html
Copyright © 2020-2023  润新知