我在理解内核线程方面遇到问题..内核线程到底是什么?
内核线程与用户进程有什么关系?映射实际上意味着什么?是程序员选择将哪个用户线程映射到哪个内核线程吗?
what do kernel threads really have to do with user process? What actually mapping means? is it the programmer who selects which user thread to map with which kernel thread?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对你的问题的简短回答:
CPU 只运行内核线程,因为内核只看到内核线程,而内核管理 CPU 调度。如果用户进程想要执行一项任务,则其中一个用户进程线程将被映射到内核线程,以便它可以由内核调度并由 CPU 运行。
程序员无需担心将用户线程映射到内核线程。也许在某些系统中,程序员可以将用户线程绑定到内核线程,但我不确定这是否可能。
Short answer to your question:
CPU only runs kernel thread, because kernel sees only kernel threads and the kernel manages CPU scheduling. If a user process wants to performance a task, one of the user process threads would be mapped to a kernel thread so it can be scheduled by kernel and ran by CPU.
Programmers do not need to worry about mapping the user threads to kernel threads. Maybe in some systems, programmer could bind a user thread to a kernel thread, but I am not sure if this is possible.