017-12-6 16:27:35
时钟中断TIMER_BH(bottom_half)实现分析
1.3.100
1. 时钟0号中断安装
    setup_x86_irq(0, &irq0);@arch/i386/kernel/time.c
        |- set_intr_gate(0x20+irq,interrupt[irq]);//interrupt[0]=IRQ0_interrupt
        
        附:IRQ0_interrupt宏函数定义:BUILD_TIMER_IRQ(FIRST,0,0x01)

#define BUILD_TIMER_IRQ(chip,nr,mask) \
asmlinkage void IRQ_NAME(nr); \
asmlinkage void FAST_IRQ_NAME(nr); \
asmlinkage void BAD_IRQ_NAME(nr); \
__asm__( \
"\n"__ALIGN_STR"\n" \
SYMBOL_NAME_STR(fast_IRQ) #nr "_interrupt:\n\t" \
SYMBOL_NAME_STR(bad_IRQ) #nr "_interrupt:\n\t" \
SYMBOL_NAME_STR(IRQ) #nr "_interrupt:\n\t" \
    "pushl $-"#nr"-2\n\t" \
    SAVE_ALL \
    ACK_##chip(mask) \
    "incl "SYMBOL_NAME_STR(intr_count)"\n\t"\
    "movl %esp,%ebx\n\t" \
    "pushl %ebx\n\t" \
    "pushl $" #nr "\n\t" \
    "call "SYMBOL_NAME_STR(do_IRQ)"\n\t" \
    "addl $8,%esp\n\t" \
    "cli\n\t" \
    UNBLK_##chip(mask) \
    "decl "SYMBOL_NAME_STR(intr_count)"\n\t" \
    "jmp ret_from_sys_call\n");
        
       
2. 时钟中断调用
    IRQ0_interrupt->do_IRQ->timer_interrupt->do_timer
     ->ret_from_sys_call->handle_bottom_half->do_bottom_half@kernel/softirq.c
    
    
另1:do_bottom_half会开启中断
asmlinkage void do_bottom_half(void)
{
    unsigned long active;
    unsigned long mask, left;
    void (**bh)(void);

sti();
    bh = bh_base;
    active = bh_active & bh_mask;
    for (mask = 1, left = ~0 ; left & active ; bh++,mask += mask,left += left) {
        if (mask & active) {
            void (*fn)(void);
            bh_active &= ~mask;
            fn = *bh;
            if (!fn)
                goto bad_bh;
            fn();
        }
    }
    return;
bad_bh:
    printk ("irq.c:bad bottom half entry %08lx\n", mask);
}

另2:ret_from_sys_call段如下:
handle_bottom_half:
    incl SYMBOL_NAME(intr_count)
    call SYMBOL_NAME(do_bottom_half)
    decl SYMBOL_NAME(intr_count)
    jmp 9f
    
...
     ret_from_sys_call:
    cmpl $0,SYMBOL_NAME(intr_count)
    jne 2f
9:    movl SYMBOL_NAME(bh_mask),%eax
    andl SYMBOL_NAME(bh_active),%eax
    jne handle_bottom_half
    movl EFLAGS(%esp),%eax        # check VM86 flag: CS/SS are
    testl $(VM_MASK),%eax        # different then
    jne 1f
    cmpw $(KERNEL_CS),CS(%esp)    # was old code segment supervisor ?
    je 2f
1:    sti
    orl $(IF_MASK),%eax        # these just try to make sure
    andl $~NT_MASK,%eax        # the program doesn't do anything
    movl %eax,EFLAGS(%esp)        # stupid
    cmpl $0,SYMBOL_NAME(need_resched)
    jne reschedule
#ifdef __SMP__
    GET_PROCESSOR_OFFSET(%eax)
    movl SYMBOL_NAME(current_set)(,%eax), %eax
#else
    movl SYMBOL_NAME(current_set),%eax
#endif
    cmpl SYMBOL_NAME(task),%eax    # task[0] cannot have signals
    je 2f
    movl blocked(%eax),%ecx
    movl %ecx,%ebx            # save blocked in %ebx for signal handling
    notl %ecx
    andl signal(%eax),%ecx
    jne signal_return
2:    RESTORE_ALL

时钟中断TIMER_BH(bottom_half)实现分析的更多相关文章

  1. KVM VCPU线程调度问题的讨论

    2017-11-15 今天闲着没有突然想了想VCPU线程调度的问题,具体描述如下: 当代表VCPU的线程获得控制权后,首先会通过KVM接口进入到内核,从内核进入到非根模式,那么此时站在全局调度器的点上 ...

  2. Linux内核源代码情景分析-中断半

    一.中断初始化 1.中断向量表IDT初始化 void __init init_IRQ(void) { int i; #ifndef CONFIG_X86_VISWS_APIC init_ISA_irq ...

  3. 【内核】linux内核启动流程详细分析

    Linux内核启动流程 arch/arm/kernel/head-armv.S 该文件是内核最先执行的一个文件,包括内核入口ENTRY(stext)到start_kernel间的初始化代码, 主要作用 ...

  4. 【内核】linux内核启动流程详细分析【转】

    转自:http://www.cnblogs.com/lcw/p/3337937.html Linux内核启动流程 arch/arm/kernel/head-armv.S 该文件是内核最先执行的一个文件 ...

  5. Linux之时钟中断

    from:深入分析Linux内核源码(http://oss.org.cn/kernel-book/) 时钟中断的产生 Linux的OS时钟的物理产生原因是可编程定时/计数器产生的输出脉冲,这个脉冲送入 ...

  6. Linux0.11内核--进程调度分析之2.调度

    [版权所有,转载请注明出处.出处:http://www.cnblogs.com/joey-hua/p/5596830.html ] 上一篇说到进程调度归根结底是调用timer_interrupt函数, ...

  7. Linux0.11内核--进程调度分析之1.初始化

    [版权所有,转载请注明出处.出处:http://www.cnblogs.com/joey-hua/p/5596746.html ] 首先看main.c里的初始化函数main函数里面有个函数是对进程调度 ...

  8. 基于Xenomai的实时Linux分析与研究

    转自:http://blog.csdn.net/cyberlabs/article/details/6967192 引 言 随着嵌入式设备的快速发展,嵌入式设备的功能和灵活性要求越来越高,很多嵌入式设 ...

  9. 《Linux内核分析》第八周 进程的切换和系统的一般执行过程

    [刘蔚然 原创作品转载请注明出处 <Linux内核分析>MOOC课程http://mooc.study.163.com/course/USTC-1000029000] WEEK EIGHT ...

随机推荐

  1. Python3 tkinter基础 Entry state 不可写 可以选 可复制的输入框

             Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda ...

  2. HDU 4825 Xor Sum(01字典树)题解

    思路:先把所有数字存进字典树,然后从最高位贪心. 代码: #include<set> #include<map> #include<stack> #include& ...

  3. IDEA 入门

    IDEA初步使用 IntelliJ IDEA 使用教程(2019图文版) -- 从入门到上瘾 IntelliJ IDEA 设置代码提示或自动补全的快捷键 (Alt+/) IntelliJ IDEA 配 ...

  4. CF776B Sherlock and his girlfriend

    题目地址 题目链接 题解 这题很有意思啊qwq.本来是写算出每个数的质约数的,然后写到一半发现,质约数互相不影响,有质约数的数肯定是合数. 所以合数染一种色,质数染一种色就好 #include < ...

  5. Hierarchical Question-Image Co-Attention for Visual Question Answering

    Hierarchical Question-Image Co-Attention for Visual Question Answering NIPS 2016 Paper: https://arxi ...

  6. 论文笔记:Learning how to Active Learn: A Deep Reinforcement Learning Approach

    Learning how to Active Learn: A Deep Reinforcement Learning Approach 2018-03-11 12:56:04 1. Introduc ...

  7. 【AI】微软人工智能学习笔记(一)

    数据分析平台 01|数据平台概况图示 上面图中所示就是微软人工智能数据平台的相关的技术. 02.1| Cortana Intelligence Suite 从上面图中可以看到, 其中有一个Cortan ...

  8. Google advertiser 开发

    开发 相关知识: 单一归因与多重归因 当展示广告网络上发生一次展示时,您可按单一归因或多重归因记录对展示起到影响作用的条件. 单一归因 在使用单一归因时,系统只为指定的展示记录一个触发条件(如展示位置 ...

  9. 5、lvs使用进阶(01)

    四层.七层负载均衡的区别  https://jaminzhang.github.io/lb/L4-L7-Load-Balancer-Difference/   netfilter/iptables简介 ...

  10. Codeforces Round #332 (Div. 2) D. Spongebob and Squares(枚举)

    http://codeforces.com/problemset/problem/599/D 题意:给出一个数x,问你有多少个n*m的网格中有x个正方形,输出n和m的值. 思路: 易得公式为:$\su ...