在可用的 LWP 上将用户级线程安排到 运行 究竟意味着什么?

What exactly does it mean to schedule user-level thread to run on an available LWP?

我想知道在 LWP 上将线程安排到 运行 究竟意味着什么。我无法正确想象当一个进程被安排到 运行 到 CPU 时发生的步骤顺序,因为很多概念都是在高层次视图中解释的。以下是导致很多人挠头的段落;它来自 操作系统概念,第 10 版,作者 A​​braham Silberschatz

One distinction between user-level and kernel-level threads lies in how they are scheduled. On systems implementing the many-to-one (Section 4.3.1) and many-to-many (Section 4.3.3) models, the thread library schedules user- level threads to run on an available LWP . This scheme is known as process- contention scope ( PCS ), since competition for the CPU takes place among threads belonging to the same process. (When we say the thread library schedules user threads onto available LWP's, we do not mean that the threads are actually running on a CPU as that further requires the operating system to schedule the LWP’s kernel thread onto a physical CPU core.)

我无法完全理解 LWP 的必要性和重要性。

就像进程是内存的容器一样,LWP(= 内核级线程)是纤程的容器(= 用户级线程,本质上)。

内核的线程调度程序只看到内核级线程 (LWP),并且它在 CPU 上和关闭 LWP 进行调度 - 也就是说,LWP 有一个时间片,它到达 运行 在 CPU 上。用户级线程库(= 纤程调度程序)拥有该进程的 LWP,并决定哪些纤程可以使用内核调度程序分配给这些 LWP 的时间片。

当纤程决定让出 CPU,但 LWP 的时间片尚未结束时,纤程调度程序将另一个纤程调度到 CPU 上 LWP 内的 运行。但是,当另一个纤程处于 运行ning 时,LWP 的时间片可能会 运行 结束,并且内核的调度程序会将该 LWP 安排在 CPU 之外。纤程调度程序不会对此事发表意见 - 纤程调度程序甚至不会达到 运行,因为它在用户空间中,内核不知道它。