Multithreaded Programming Guide

Lightweight Processes

The threads library uses underlying threads of control called lightweight processes that are supported by the kernel. You can think of an LWP as a virtual CPU that executes code or system calls.

You usually do not need to concern yourself with LWPs to program with threads. The information here about LWPs is provided as background, so you can understand the differences in scheduling scope, described on Process Scope (Unbound Threads).

Much as the stdio library routines such as fopen() and fread() use the open() and read() functions, the threads interface uses the LWP interface, and for many of the same reasons.

Lightweight processes (LWPs) bridge the user level and the kernel level. Each process contains one or more LWP, each of which runs one or more user threads. (See Figure 1–1.)

Figure 1–1 User-level Threads and Lightweight Processes

Diagram showing bound and unbound threads connecting to lightweight process

Each LWP is a kernel resource in a kernel pool, and is allocated and de-allocated to a thread on a per thread basis.