您的位置:首页 > Web前端

What is the difference between LWP and threads?

2013-01-22 16:39 585 查看
This explains the difference between LWP-Process-Thread:

A light-weight process (LWP)
is a means of achieving multitasking. In contrast to a regular (full-blown) process, an LWP shares all (or most of) its logical address space and system resources with other process(es); in contrast to a thread, a light-weight process has its own private process
identifier and parenthood relationships with other processes. Moreover, while a thread can either be managed at the application level or by the kernel, an LWP is always managed by the kernel and it is scheduled as a regular process. One significant example
of a kernel that supports LWPs is the Linux kernel.

On most systems, a light-weight process also differs from a full-blown process, in that it only consists of the bare minimum execution context and accounting information that
is needed by the scheduler, hence the term light-weight.
Generally, a process refers to an instance of a program, while an LWP represents a thread of execution of a program (indeed, LWPs can be conveniently used to implement threads, if the underlying kernel does not directly support them). Since a thread of execution
does not need as much state information as a process, a light-weight process does not carry such information.

As a consequence of the fact that LWPs share most of their resources with other LWPs, they are unsuitable for certain applications, where multiple full-blown processes are
needed, e.g. to avoid memory leaks (a process can be replaced by another one) or to achieve privilege separation (processes can run under other credentials and have other permissions). Using multiple processes also allows the application to more easily survive
if a process of the pool crashes or is exploited.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: