User-level thread and kernel-level thread overview

  
 

In multi-threaded operating system
, each system is implemented differently. In some systems, user-level threads are implemented, and some systems implement kernel-level threads.

1. Kernel-level threads:

(1) Thread creation, revocation, and switching, etc. Both require a direct kernel implementation, ie the kernel knows every thread that is a schedulable entity. (2) These threads can compete for resources throughout the system. (3) A thread control block (TCB) is set in the kernel space for each kernel support thread, and the kernel senses the existence of the thread and controls according to the control block. To some extent, it is similar to a process, except that the overhead of creating and scheduling is smaller than the process. Some statistics are 1:10

2. User-level threads:

(1) User-level threads exist only in user space. ——>Comparing the kernel (3)(2) kernel does not see the user thread. ——> Important differences (3) The allocation of kernel resources is still allocated according to the process; each user thread can only compete for resources within the process.

User threads run on an intermediate system. At present, there are two ways to implement the intermediate system, namely the runtime system (Runtime System) and the kernel control thread. "Runtime system" is a collection of functions that are used to manage and control threads. Functions that include create, undo, thread synchronization and communication, and scheduled functions. These functions reside in user space as an interface between the user thread and the kernel. User threads cannot use system calls. Instead, when a thread needs system resources, it passes the request to the runtime, which gets the system resources through the corresponding system call. Kernel control thread: The system distributes several light processes (LWP) to the process. The LWP can obtain the services provided by the kernel through system calls, and the user threads in the process can be associated with the LWP through multiplexing to obtain the services of the kernel.

The advantages of kernel threads: (1) (2) When there are multiple processors, multiple threads of a process can execute at the same time: (1) scheduling by the kernel

user Advantages of the process: (1) The scheduling of the thread does not require the direct participation of the kernel, and the control is simple. Disadvantages: (1) The resource scheduling is performed according to the process. Under multiple processors, the threads in the same process can only be divided into the same processor. Time multiplexing.

Copyright © Windows knowledge All Rights Reserved