2

用户级线程如何映射到内核级线程?

4

2 回答 2

1

It varies by implementation. The three most common threading models are:

  1. 1-to-1: Each user-level thread has a corresponding entity that is scheduled by the kernel.

  2. n-to-1: Each process is scheduled by the kernel. Thread scheduling takes place entirely in user space.

  3. n-to-m: Each process has a pool of entities that are scheduled by the kernel. These are assigned to run particular user-level threads by a user-space scheduler that is part of the process.

Modern implementations are almost all 1-to-1.

于 2013-02-09T22:46:25.687 回答
0

用于指代 ULT 和 KLT 的术语有些混乱。以下是两种不同的解释。如果我错了,请纠正我:

  1. KLT 需要在内核中实现并发(注意将内核解释为进程或活动实体)。对于像 Symbian 这样的微内核来说也是如此,其中内核线程负责系统的每个硬件资源(例如文件服务器、位置服务器、日历服务器等)。然而,在像 Linux 这样的内核中,它主要是一个库(而不是一个进程或一个独立的生命实体),内核线程实际上没有任何意义。在 Linux 中,您创建的每个线程都被内核视为一个进程,并且内核始终在进程上下文或中断上下文中运行。

  2. 第二种解释是基于线程(或并发)是否对内核可见。例如,使用 setjmp、longjmp 可以在用户空间实现并发。就像已经讨论过的那样,内核完全没有意识到这一点。这种并发性可以称为 ULT。并且内核知道其创建的线程(使用 Clone() 系统调用的线程)可以称为 KLT。

于 2013-02-12T06:40:30.713 回答