What exactly is the lwp and threads in solaris

multithreadingsolaristhread

The book "Solaris Internals" says

Solaris executes kernel threads for kernel-related tasks, such as interrupt handling, memory page management, device drivers, etc. For user-process execution, kernel threads have a corresponding LWP; these kernel threads are scheduled for execution by the kernel on behalf of the user processes

I am a little confused about the words and below is my understanding

In solaris, the "real thread" is the "kernel thread". The kernel threads can execute kernel-related tasks and user-related tasks. When execute user-related tasks, the kernel thread needs a data structure called LWP to provide the environment.
So, the user thread and LWP are not the execution unit or thread at all. They are just data structres in the system. The user thread is just the user task needed to be executed which includes the user data and code. The LWP is the kernel data structure providing the kernel infomation. The real execution unit or flow is kernel thread.

Provided my understanding is correct, in the early solaris where two-level thread model exists, many user threads can be bound to one lwp which means that in the underlying implementation of solaris the "many user thread" are really one thread(kernel thread) to the kernel or CPU and the only kernel thread executes the tasks in each user thread in turn. If the user thread is unbound it can not be executed.

Am I right?

Best Answer

Kernel thread is the fundamental entity scheduled on the system CPU which is very light.

Kernel threads have a one-to-one mapping with an LWP. The thread-library schedules a user thread onto an LWP. sources:

Related Question