设置多核 x86 处理器中的关联性

发布于 2024-07-25 09:49:57 字数 134 浏览 5 评论 0原文

(我问这个问题是因为我在认真研究操作系统之前就已经开始研究 SMP 和多核了。我喜欢了解代码是如何执行的。)

如果我有一个多核 x86 CPU 直接启动到我的程序中。 有人可以推荐一个网站来描述我必须使用哪些汇编器命令来控制亲和力吗?

( I ask because it was before serious SMP and multicore that I studied OS. I like to have some vision of how code is being executed. )

If I have a multicore x86 CPU booting directly into my program. Can someone recommend a website which describes what assembler commands do I have to control affinity?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

只等公子 2024-08-01 09:49:57

关联性不是由 CPU 状态决定的,因此不能通过汇编(单独)进行修改。 你需要操作系统的参与。 每个操作系统都会有一个特定的调用来执行此操作。

操作系统将做什么:操作系统将有一个调度程序,它实际上是一个程序,用于确定哪个进程在哪个处理器上运行。 通过将关联性设置为用户,您可以配置此调度程序。

如果您没有操作系统(我认为这个问题似乎暗示了这一点),那么您将自己编写调度程序,并且您将拥有对配置的自己的控制权,并且您可能会从全局运行队列开始,并为每个处理器(核心)监视此运行队列,并检索要从中运行的进程。

那么这是如何运作的呢? 启动期间,只有一个 CPU 正在运行。 如果操作系统已做好准备,您将“启动”其他 CPU,它们开始执行您的代码,并且可能会运行某种调度程序。

有关示例实现,请参阅 Linux 2.6.29 arch/x86/kernel/smpboot.c 函数 do_boot_cpu(),它使用 APIC 以多种方式使 CPU 联机。

Affinity is not determined by the CPU state and can therefore not be modified by assembly (alone). You need participation of the OS. And each OS will have a specific call to do this.

What the OS will do: the OS will have a scheduler, which is in effect a program who determines which process runs when on what processor. With setting the affinity as a user, you configure this scheduler.

And if you wouldn't have a OS (which the question seems to imply I think), then you're writing the scheduler yourself and you will have own control of the configuration and you will probably start with a global runqueue and for each processor (core) watch this runqueue, and retrieve processes to run from it.

So how does this work then? During boot, only one CPU is running. If you as the OS are ready for it, you 'boot' the other CPUs which start executing your code, and which will probably run a kind of scheduler.

For an example implementation, see Linux 2.6.29 arch/x86/kernel/smpboot.c function do_boot_cpu(), which brings a CPU online in several ways using APIC.

入画浅相思 2024-08-01 09:49:57

这里有一个关于 QNX 如何做到这一点的很好的解释。 它并没有提供所需的 ASM(无论如何,这将取决于平台),但它可能有助于概念:

http://www.embedded.com/columns/technicalinsights/183702309?_requestid=408789

以及来自同一网站的一系列文章

http://www.embedded.com/products/integrated Circuits/173400008?_requestid=409058

Here's a pretty good explanation of how QNX does it. It doesn't go as far as supplying the required ASM (which would be platform dependant anyway) but it may help with the concepts:

http://www.embedded.com/columns/technicalinsights/183702309?_requestid=408789

and a range of articles from the same site

http://www.embedded.com/products/integratedcircuits/173400008?_requestid=409058

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文