In Linux, a lightweight process can be a process, or it can be a thread. What we call threads, in Linux, is actually the lightweight process of sharing code snippets, file descriptors, signal processing, global variables when;
If not shared, it is what we call a process.
A process is the smallest unit of resource management, and a thread is the smallest unit of program execution. In the design of the operating system, the main purpose of the process evolution is to reduce the cost of multi-process context switching.
The initial process definition contains the program, the resource and its execution three parts, in which the program usually refers to the code, resources at the operating system level usually includes memory resources, IO resources, signal processing and other parts,
The execution of the program is generally understood as the execution context, including the CPU footprint, which later evolved into a thread. In order to reduce the overhead of process switching, the operating system designers gradually corrected the process before the thread concept appeared
concept, gradually allowing the resources occupied by the process to be stripped out of its principal, allowing some processes to share some of the resources, such as files, signals, data memory, and even code, to develop the concept of a lightweight process.
The Linux kernel has already implemented a lightweight process in the 2.0.x version, and the application can use a unified clone () system call interface, with different parameters to specify whether to create a lightweight process or a normal process.
Lightweight processes in Linux