Com base no meu entendimento do Understanding the Linux Kernel, é correto que:
-
threads do kernel e processos leves no kernel Linux são representados por task_struct
structure em C.
Os encadeamentos do kernel -
sempre são executados no espaço do kernel, enquanto os processos leves podem ser executados no espaço do usuário e no espaço do kernel
-
threads do kernel e processos leves são dois conceitos no mesmo nível. Eles não dependem um do outro? Em particular, um processo leve não é criado e executado com base em um encadeamento do kernel?
Então, por que a seguinte citação do Operating System Concepts significa dizer que um processo leve está anexado a um segmento do kernel? (Note que este livro é para conceitos gerais do sistema operacional, e a citação não diz que é para o Linux, mas a maioria das partes do livro é aplicável ao Linux)
A final issue to be considered with multithreaded programs concerns
communication between the kernel and the thread library, which may be
required by the many-to-many and two-level models discussed in Section
4.3.3. Such coordination allows the number of kernel threads to be dynamically adjusted to help ensure the best performance.
Many systems implementing either the many-to-many or the two-level
model place an intermediate data structure between the user and
kernel threads. This data structure—typically known as a
lightweight process, or LWP—is shown in Figure 4.13. To the
user-thread library, the LWP appears to be a virtual processor on
which the application can schedule a user thread to run. Each LWP is
attached to a kernel thread, and it is kernel threads that the
operating system schedules to run on physical processors. If a
kernel thread blocks (such as while waiting for an I/O operation to
complete), the LWP blocks as well. Up the chain, the user-level thread
attached to the LWP also blocks.
onde vários conceitos são definidos no livro como a seguir, em particular as definições de threads do kernel e threads do usuário podem ser diferentes daquelas que eu mencionei nas minhas perguntas no início deste post:
support for threads may be provided either at the user level, for user threads, or by the
kernel, for kernel threads. User threads are supported above the kernel and
are managed without kernel support, whereas kernel threads are supported
and managed directly by the operating system.
The many-to-one model (Figure 4.5) maps many user-level threads to one
kernel thread. Thread management is done by the thread library in user
space, so it is efficient
The many-to-many model (Figure 4.7) multiplexes many user-level
threads to a smaller or equal number of kernel threads. The number of
kernel threads may be specific to either a particular application or a
particular machine (an application may be allocated more kernel
threads on a multiprocessor than on a single processor).
Obrigado.