在不同处理器上运行代码(x86 程序集)
在 x86 上的实模式下,需要使用哪些指令在多处理器系统中的不同处理器上运行代码?
(我正在汇编器中编写一些预启动代码,需要设置某些 CPU 寄存器,并在实际操作系统启动之前在系统中的每个 CPU 上执行此操作。)
In real mode on x86, what instructions would need to be used to run the code on a different processor, in a multiprocessor system?
(I'm writing some pre-boot code in assembler that needs to set certain CPU registers, and do this on every CPU in the system, before the actual operating system boots.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
那么您有一个独立的(您说“预启动”)程序,例如引导加载程序,以实模式运行?这是在具有通常 BIOS 的 PeeCee 上吗?
在这种情况下,您只有一个 CPU 正在运行。为了启动其他 CPU 单元,操作系统通常会执行所谓的通用启动算法,如下所示:
BSP 是引导处理器。 AP 是应用程序处理器。 IPI 是处理器间中断。为了执行 IPI,您需要启用 APIC,这是 PC 架构的中断控制器扩展,但在启动时不会启用。这就是为什么代码担心它正在运行什么样的 ICU 版本。所有这些都是相当深奥的内核魔法。您可以尝试查看 Linux、NetBSD 或其他 *BSD 源代码作为示例,但它并不容易阅读。如果你真的赢了,你可能会在某个地方找到一个小内核或独立的 SMP 测试程序。
如需了解更多信息,请参阅英特尔多处理器规范。
So you have a stand-alone (you said "pre-boot") program, like a bootloader, running in real mode? And this is on a PeeCee with the usual BIOS?
In that case you have only one CPU running. In order to spin-up the other CPU units an operating system will typically execute what is called the universal startup algorithm which goes like this:
The BSP is the Boot Processor. An AP is an Application Processor. An IPI is an inter-processor interrupt. In order to do an IPI, you need to enable the APIC, an interrupt controller extension to the PC architecture which is not enabled at bootup. That's why the code is worried about what kind of ICU version it is running. All of this is fairly deep kernel magic. You might try looking at Linux, NetBSD, or other *BSD source code for an example, but it won't be easy to read. If you really win, you might find a small kernel or standalone SMP test program out there somewhere.
For more information, see the Intel Multiprocessor Specification.