中断在多核系统中是如何工作的? [英] How do interrupts work in multi-core system?

查看:27
本文介绍了中断在多核系统中是如何工作的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为Raspberry pi 2上的按钮中断编写代码.该板使用四核Broadcom BCM2836 CPU(ARM架构).这意味着,该板上只有一个 CPU(Raspberry pi 2).但是我不知道在多核系统中如何中断.我想知道中断线是连接到每个内核还是一个CPU.所以,我通过谷歌找到了下面的段落.

I want to write code for interrupts of the buttons on Raspberry pi 2. This board uses QUAD Core Broadcom BCM2836 CPU (ARM architecture). That mean, only one CPU is on this board( Raspberry pi 2 ). But I don't know how do interrupts in multi-core system. I wonder whether interrupt line is connected to each core or one CPU. So, I found the paragraph below via Google.

多核系统上的中断在多核系统上,每个中断都指向一个(并且只有一个)CPU,尽管与哪个无关.这是如何发生的由板上的可编程中断控制器芯片控制.当您在系统启动时初始化 PIC 时,您可以对它们进行编程以将中断传送到您想要的任何 CPU;在某些 PIC 上,您甚至可以让中断在每次关闭时在 CPU 之间轮换.

这是否意味着每个 CPU 都会发生中断?我无法完全理解上述信息.如果每个内核都发生中断,我必须考虑按钮的每个中断服务例程上共享数据的临界区.

Is this mean that interrupts happen with each CPU ? I can't understand exactly above info. If interrupts happen to each core, I must take account of critical section for shared data on each interrupt service routine of the buttons.

如果每个 CPU 发生中断,我就不必考虑共享数据的临界区.什么是正确的?

If interrupts happen to each CPU, I don't have to take account of critical section for shared data. What is correct?

总结一下,我想知道多核系统中的中断怎么办?中断线是连接到每个内核还是CPU?那么,我是否应该考虑相同中断的临界区?

To sum up, I wonder How do interrupts in multi-core system? Is the interrupt line is connected to each core or CPU? So, should I have to take account of critical section for same interrupt?

推荐答案

您从 google 引用的内容看起来很一般,甚至可能依赖于 x86 的大小,但如果是这种情况,则无关紧要.

your quote from google looks quite generic or perhaps even leaning on the size of x86, but doesnt really matter if that were the case.

我当然希望你能够控制每个 cpu 的中断,这样你就可以让一种类型转到一种类型,另一种类型转到另一种类型.

I sure hope that you would be able to control interrupts per cpu such that you can have one type go to one and another to another.

同样,如果您愿意,也可以选择将它们全部中断.

Likewise that there is a choice to have all of them interrupted in case you want that.

中断与共享资源无关,无论是否在ISR中,您都必须处理共享资源,因此中断无关紧要,您必须处理它.具有将中断从一个外设隔离到一个 cpu 的能力可以使共享更容易,因为您可以让一个 cpu 拥有资源,而其他 cpu 向拥有它的 cpu 发出请求,例如.

Interrupts are irrelevant to shared resources, you have to handle shared resources whether you are in an ISR or not, so the interrupt doesnt matter you have to deal with it. Having the ability to isolate interrupts from one peripheral to one cpu could make the sharing easier in that you could have one cpu own a resource and other cpus make requests to the cpu that owns it for example.

双核、四核等无关紧要,将每个核视为单个 CPU,事实就是如此,并像处理单个 CPU 一样解决中断问题.再次共享资源是共享资源,在中断期间或不在中断期间.解决一个cpu的问题,然后处理任何共享.

Dual, Quad, etc cores doesnt matter, treat each core as a single cpu, which it is, and solve the interrupt problems as you would for a single cpu. Again shared resources are shared resources, during interrupts or not during interrupts. Solve the problem for one cpu then deal with any sharing.

作为 ARM,每个芯片供应商的实现可能会有所不同,因此不可能有一个通用的答案,您还必须阅读 arm 核心的 arm 文档(如果可能,特定版本可能/确实有所不同)正如芯片供应商记录了他们在 arm 核心周围所拥有的一切.在这种情况下,作为博通,芯片供应商文档祝你好运.它们充其量是有限的,尤其是 raspi2.您可能需要深入研究 linux 源代码.不管是 arm、x86、mips 等等,你只需要阅读文档并做一些实验.首先将每个内核视为独立的 CPU,然后根据需要处理资源共享.

Being an ARM each chip vendors implementation can vary from another, so there cannot be one universal answer, you have to read the arm docs for the arm core (and if possible the specific version as they can/do vary) as well as the chip vendors docs for whatever they have around the arm core. Being a Broadcom in this case, good luck with chip vendor docs. They are at best limited, esp with the raspi2. You might have to dig through the linux sources. No matter what, arm, x86, mips, etc, you have to just read the documentation and do some experiments. Start off by treating each core as a standalone cpu, then deal with sharing of resources if required.

如果我没记错的话,默认情况是只有第一个内核在 SD 卡上运行 kernel7.img,其他三个内核在循环中旋转,等待写入地址(每个都有自己的地址)以获取他们跳到那个并开始做其他事情.所以你真的可以从一个单一的 CPU 开始,不共享,然后弄清楚,如果你选择在其他 CPU 上没有接触该资源的代码,那就完成了.如果你这样做,那么找出如何共享资源.

If I remember right the default case is to have just the first core running the kernel7.img off the sd card, the other three are spinning in a loop waiting for an address (each has its own) to be written to get them to jump to that and start doing something else. So you quite literally can just start off with a single cpu, no sharing, and figure that out, if you choose to not have code on the other cpus that touch that resource, done. if you do THEN figure out how to share a resource.

这篇关于中断在多核系统中是如何工作的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆