[英]Many-to-one mapping of user threads to a kernel thread
As I understand it, in many-to-one mapping, one kernel thread manages many user threads. 据我了解,在多对一映射中,一个内核线程管理着许多用户线程。 This kernel thread helps the user threads make system calls etc. What I don't understand is: 这个内核线程帮助用户线程进行系统调用等。我不明白的是:
1) Why do we have many-to-one mapping if a single blocking call would block all user threads managed by the kernel thread? 1)如果单个阻塞调用会阻塞内核线程管理的所有用户线程,为什么我们会有多对一映射?
The drawback of having one-to-one mapping is involvement of kernel when there is a context switch between the threads. 一对一映射的缺点是在线程之间进行上下文切换时会涉及内核。 Involvement of kernel results in several overheads. 涉及内核会导致一些开销。
2)In many-to-one mapping of user threads to a kernel thread, do all the user threads have to be from the same process? 2)在用户线程到内核线程的多对一映射中,是否所有用户线程都必须来自同一进程?
Yes 是
3)In many-to-one mapping, can all the user threads be run on different cores/CPUs at once or is only one of them run at a time? 3)在多对一映射中,所有用户线程可以一次在不同的内核/ CPU上运行还是一次只能运行一个?
The pro feature of having a many-one mapping is that entire thread context-switching is maintained by the user-level thread library you use and as far as kernel is concerned it doesn't know how many threads you have it gives the process a time slice to execute and it's up to the thread library to give control to any of the threads. 多对一映射的优点是,整个线程上下文切换由您使用的用户级线程库维护,就内核而言,它不知道您拥有多少个线程,从而为进程提供了一个时间片的执行时间,由线程库决定是否对任何线程进行控制。 From this, you can easily see that in many-to-one mapping at any instant only one thread of the process can get the control. 由此,您可以轻松地看到,在任何时候的多对一映射中,只有进程的一个线程才能获得控件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.