简体   繁体   English

用户线程到内核线程的多对一映射

[英]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 ? 如果单个阻塞调用会阻塞内核线程管理的所有用户线程,为什么我们会有多对一映射?
  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 ? 在多对一映射中,所有用户线程可以一次在不同的内核/ CPU上运行还是一次只能运行其中一个?

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.

相关问题 用户线程和内核线程是否通过以下任一方式对应线程级库和内核级库? - Do user threads and kernel threads correspond to thread-level library and kernel-level library in any of the following ways? 一个线程提供数据的最快实现,许多线程消耗数据 - Fastest implementation of one thread providing data, many threads consuming data 用于C守护程序的多对一IPC - Which many-to-one IPC for C daemon 单独程序的多对一双向通信 - Many-to-one two-way communication of separate programs 内核,内核线程和用户线程之间的区别 - Difference between Kernel, Kernel-Thread and User-Thread 内核线程与用户线程之间的上下文切换 - Context switch between kernel threads vs user threads Linux 用户空间线程、内核线程、轻量级进程 - Linux user space threads, kernel threads , lightweight processes Linux - 在内核代码中映射用户空间内存 - Linux - Mapping user space memory in kernel code 为什么 kernel 调度到 modprobe 线程打印这个不是 kernel 线程的线程的日志? - Why does the kernel schedule to modprobe threads print this the log of a thread that is not a kernel thread? Linux内核线程在CPU硬件线程上是否映射1:1或m:n? - Does linux kernel thread map 1:1 or m:n on cpu hardware threads?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM