简体   繁体   English

多核Linux内核中的上下文切换

[英]Context Switches in Linux Kernel on Multicore

Does Linux Kernel perform multiple context switches concurrently, if required in parallel on more than one cores of a multicore processor machine? 如果需要,Linux内核是否可以在多核处理器计算机的多个内核上并行执行多个上下文切换? Any reference? 有参考吗?

Yeah, you're right. 是啊,你说得对。 On SMP system, multiple context switches happen concurrently. 在SMP系统上,多个上下文切换同时发生。 Each core can do context switch independently. 每个内核可以独立进行上下文切换。 Of course, if needed, spinlock_* is needed to protect critical section. 当然,如果需要,则需要spinlock_ *以保护关键部分。

Maybe you want to know when will one core decide to do context switch, there are several situations: 也许您想知道一个核心何时决定进行上下文切换,有几种情况:

(1) Interrupts happen; (1)发生中断;

(2) Exceptions happen; (2)发生异常;

(3) User process system call; (3)用户进程系统调用;

(4) In kernel space(not interrupt/exception context), there are also codes which call schedule() to give up CPU; (4)在内核空间(不是中断/异常上下文)中,还有一些代码调用schedule()放弃CPU;

(5) ...; (5)...;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM