用户线程到内核线程的多对一映射
Many-to-one mapping of user threads to a kernel thread
据我了解,在多对一映射中,一个内核线程管理多个用户线程。这个内核线程帮助用户线程进行系统调用等。我不明白的是:
- 如果单个阻塞调用可以,为什么我们会有多对一映射
阻止内核线程管理的所有用户线程?
- 在用户线程到内核线程的多对一映射中,执行所有
用户线程必须来自同一个进程?
- 在多对一的映射中,所有的用户线程可以运行在不同的
一次 cores/CPUs 或一次只有其中一个 运行 ?
1) Why do we have many-to-one mapping if a single blocking call would
block all user threads managed by the kernel thread?
具有一对一映射的缺点是当线程之间存在上下文切换时内核会参与其中。内核的参与会导致一些开销。
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?
是
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?
多对一映射的优点是整个线程上下文切换由您使用的用户级线程库维护,就内核而言,它不知道您有多少线程它给进程一个时间片来执行,并且由线程库来控制任何线程。由此,您可以很容易地看出,在多对一映射中,在任何时刻只有进程的一个线程可以获得控制权。
据我了解,在多对一映射中,一个内核线程管理多个用户线程。这个内核线程帮助用户线程进行系统调用等。我不明白的是:
- 如果单个阻塞调用可以,为什么我们会有多对一映射 阻止内核线程管理的所有用户线程?
- 在用户线程到内核线程的多对一映射中,执行所有 用户线程必须来自同一个进程?
- 在多对一的映射中,所有的用户线程可以运行在不同的 一次 cores/CPUs 或一次只有其中一个 运行 ?
1) Why do we have many-to-one mapping if a single blocking call would block all user threads managed by the kernel thread?
具有一对一映射的缺点是当线程之间存在上下文切换时内核会参与其中。内核的参与会导致一些开销。
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?
是
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?
多对一映射的优点是整个线程上下文切换由您使用的用户级线程库维护,就内核而言,它不知道您有多少线程它给进程一个时间片来执行,并且由线程库来控制任何线程。由此,您可以很容易地看出,在多对一映射中,在任何时刻只有进程的一个线程可以获得控制权。