交替线程
您能为我指出一个方向,让我发现 Linux 内核中线程是如何交替的吗?
Could you point me in a direction for discovering how threads are being alternated in the Linux kernel?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
虽然我对内核没有深入的了解,但据我所知,内核
线程
(&进程
)显示为任务
。任务
之间的切换称为上下文切换
。上下文切换由调度程序通过schedule
调用触发,该调用位于kernel/sched.c
中(http://lxr.linux.no/linux+v3.0.4/kernel/sched.c#L4247 )。在schedule
函数context_switch
中被调用,该函数切换内存映射和内存映射。为新线程注册值。我建议查看schedule
函数。PS:您可以使用http://lxr.linux.no在线浏览内核代码。
希望这有帮助!
Although I do not possess in depth knowledge about the kernel, but AFAIK to the kernel
threads
(&processes
) appear astasks
. The switching betweentasks
is known ascontext switch
. Context switch is triggered by scheduler throughschedule
call which is present inkernel/sched.c
( http://lxr.linux.no/linux+v3.0.4/kernel/sched.c#L4247 ). Inschedule
functioncontext_switch
is called which switches memory map & register values for the new thread. I would suggest looking atschedule
function.P.S.: You can use http://lxr.linux.no for browsing kernel code online.
Hope this helps!