running multiple instances of a same interrupt parallely on an SMP system

不羁岁月 提交于 2020-03-06 06:58:06

问题


Is it possible to run multiple instances of a same interrupt simultaneously on a multi processor system in linux? If not possible, why do we need to synchronize between interrupt handlers using spin locks?

Thanks Venkatesh


回答1:


On a SMP architecture Advanced Programmable Interrupt Controller(APIC) is used to route the interrupts from peripherals to the CPU's.

the APIC, based on
1. the routing table (where interrupt affinity is set to a particular processor),
2. priority of the interrupt,
3. the load on the CPU's

For example, consider a interrupt is received at IRQ line 32, this goes through APIC,the interrupt is routed to a particular CPU, for now consider CPU0, this interrupt line is masked until the ISR is handled, which means you will not get a interrupt of the same type if ISR execution is in progress

Once ISR is handled, only then the interrupt line is unmasked for future interrupts




回答2:


Is it possible to run multiple instances of a same interrupt simultaneously on a multi processor system in linux?

The interrupt handlers are generally serialized. Meaning, that only one instance of the handler would be running(on either of the processors). While this is running, if same type of interrupt is again generated, it is processed only after the current one is done, thus serialized. While "this" handler is being executed by one of the core, other core might service handler of a different instance.

Why do we need to synchronize between interrupt handlers using spin locks?

The spinlocks are used even in such cases as the data has to be protected against some other threads(for example bottom halved, user read/write handler functions, etc). The scenario could be something like this :

my_ISR()
{
    lock(&l);
    // data is accessed here
    unlock(&l);    
}

my_other_thread()
{
    lock(&l);
    // same data is accessed here
    unlock(&l);
}


来源:https://stackoverflow.com/questions/25144582/running-multiple-instances-of-a-same-interrupt-parallely-on-an-smp-system

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!