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

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

问题描述

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

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之间轮换.

Interrupts on multi-core systems On a multi-core system, each interrupt is directed to one (and only one) CPU, although it doesn't matter which. How this happens is under control of the programmable interrupt controller chip(s) on the board. When you initialize the PICs in your system's startup, you can program them to deliver the interrupts to whichever CPU you want to; on some PICs you can even get the interrupt to rotate between the CPUs each time it goes off.

这是否意味着每个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文档(以及可能的具体版本,因为它们可能/会有所不同).作为芯片供应商的文档,他们提供了有关手臂核心的任何信息.在这种情况下成为Broadcom,请与芯片供应商的文档打个招呼.它们充其量是有限的,尤其是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,其他三个正在循环旋转,等待写入地址(每个地址都有自己的地址)他们跳到那开始做其他事情.因此,如果您选择在其他cpus上没有接触该资源的代码,那么从字面上看,您可以只从一个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天全站免登陆