+ -
当前位置:首页 → 问答吧 → 2.6下的抢占,软中断也可以吗?

2.6下的抢占,软中断也可以吗?

时间:2010-11-20

来源:互联网

本帖最后由 donotgiveup 于 2010-11-20 22:53 编辑

同一个cpu上,软中断可以抢占吗?同级的不能抢占,高级的可以吧?

看了下,__do_softirq

asmlinkage void __do_softirq(void)
{
        struct softirq_action *h;
        __u32 pending;
        int max_restart = MAX_SOFTIRQ_RESTART;
        int cpu;

        pending = local_softirq_pending();
        account_system_vtime(current);

        __local_bh_disable((unsigned long)__builtin_return_address(0));
        lockdep_softirq_enter();

        cpu = smp_processor_id();
restart:
        /* Reset the pending bitmask before enabling irqs */
        set_softirq_pending(0);

        local_irq_enable();

        h = softirq_vec;

        do {
                if (pending & 1) {
                        int prev_count = preempt_count();
                        kstat_incr_softirqs_this_cpu(h - softirq_vec);

                        trace_softirq_entry(h, softirq_vec);
                        h->action(h);
                        trace_softirq_exit(h, softirq_vec);
                        if (unlikely(prev_count != preempt_count())) {
                                printk(KERN_ERR "huh, entered softirq %td %s %p"
                                       "with preempt_count %08x,"
                                       " exited with %08x?\n", h - softirq_vec,
                                       softirq_to_name[h - softirq_vec],
                                       h->action, prev_count, preempt_count());
                                preempt_count() = prev_count;
                        }

                        rcu_bh_qsctr_inc(cpu);
                }
                h++;
                pending >>= 1;
        } while (pending);

        local_irq_disable();

        pending = local_softirq_pending();
        if (pending && --max_restart)
                goto restart;

        if (pending)
                wakeup_softirqd();

        lockdep_softirq_exit();

        account_system_vtime(current);
        _local_bh_enable();
}
看这个代码好像是不能抢占的,即使优先级更高

顺便请问下,软中断多了是否会丢失?

作者: donotgiveup   发布时间: 2010-11-20

会,软中断的触发完全就是设置一个标志位.

作者: tempname2   发布时间: 2010-11-20