Linux 是否会在所有内核上都进入内核?

发布于 2024-08-17 06:08:45 字数 140 浏览 2 评论 0原文

对于运行Linux 2.6.x的多核计算机,当线程进行系统调用时会发生什么?它是仅在线程运行的核心上落入内核,还是在所有核心上落入内核(抱歉,如果这是一个新手问题)。

一般来说,这种行为(以正确的行为为准)在接收中断时是否相同?如果不是,有什么区别?

For a multi-core computer running Linux 2.6.x, what happens when a thread makes a system call? Does it drop into the kernel only on the core that the thread is running on, or does it drop into the kernel on all cores (sorry if this is a newbie question).

Is this behaviour (whichever is the correct one) the same when receiving interrupts in general? If not, what are the differences?

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

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

发布评论

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

评论(2

奈何桥上唱咆哮 2024-08-24 06:08:45

只有执行系统调用的线程才会进入内核。 Linux 中的所有调度都是在线程粒度上完成的。至于中断 - 它们被路由到一个核心,即对于每个给定的硬件事件只有一个处理器被中断。然后可以手动将中断分配给特定的内核。这是通过 /proc/irq/IRQ-NUMBER/smp_affinity 中的掩码完成的。您可以在 /proc/interrupts 中查看哪些 CPU 接收哪些硬件中断。

Only the thread that does the syscall enters the kernel. All scheduling in Linux is done on thread granularity. As for interrupts - they are routed to one core, i.e. only one processor is interrupted for each given hardware event. Then interrupts could be manually assigned to specific cores. This is done with a mask in /proc/irq/IRQ-NUMBER/smp_affinity. You can see which CPUs receive what hardware interrupts in /proc/interrupts.

2024-08-24 06:08:45

只有一个核心处理系统调用,并且只有一个核心处理中断。

我没有任何关于中断具体如何路由的参考资料 - 也许英特尔系统编程指南 在这里会有帮助。

但是,想象一下如果所有内核都被每个系统调用或中断中断。 Linux 被设计为可扩展到多个内核。这会破坏可扩展性——在大型服务器上,每个磁盘 I/O、计时器中断等都会有效地停止系统中的每个核心,阻止它们执行有用的工作。

Ony one core handles a system call, and only one core handles an interrupt.

I don't have any references off hand for exactly how interrupts are routed - perhaps Intel's System Programming Guide would be helpful here.

But, imagine if all cores were interrupted by every system call or interrupt. Linux is designed to scale to many cores. This would kill that scalability - on a massive server every disk I/O, timer interrupt, etc., would effectively stall every single core in the system, preventing them from doing useful work.

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