官术网_书友最值得收藏!

Linux support for threads

The flow of execution in a process is referred to as a thread, which implies that every process will at least have one thread of execution. Multi-threaded means the existence of multiple flows of execution contexts in a process. With modern many-core architectures, multiple flows of execution in a process can be truly concurrent, achieving fair multitasking.

Threads are normally enumerated as pure user-level entities within a process that are scheduled for execution; they share parent's virtual address space and system resources. Each thread maintains its code, stack, and thread local storage. Threads are scheduled and managed by the thread library, which uses a structure referred to as a thread object to hold a unique thread identifier, for scheduling attributes and to save the thread context. User-level thread applications are generally lighter on memory, and are the preferred model of concurrency for event-driven applications. On the flip side, such user-level thread model is not suitable for parallel computing, since they are tied onto the same processor core to which their parent process is bound.

Linux doesn’t support user-level threads directly; it instead proposes an alternate API to enumerate a special process, called light weight process (LWP), that can share a set of configured resources such as dynamic memory allocations, global data, open files, signal handlers, and other extensive resources with the parent process. Each LWP is identified by a unique PID and task structure, and is treated by the kernel as an independent execution context. In Linux, the term thread invariably refers to LWP, since each thread initialized by the thread library (Pthreads) is enumerated as an LWP by the kernel.

主站蜘蛛池模板: 建德市| 山丹县| 南靖县| 高安市| 临漳县| 荥经县| 广昌县| 浠水县| 竹北市| 嘉善县| 凯里市| 青神县| 集贤县| 汝阳县| 图木舒克市| 三台县| 申扎县| 襄汾县| 崇阳县| 尼勒克县| 南安市| 兴义市| 隆昌县| 安宁市| 连州市| 大冶市| 思南县| 永平县| 观塘区| 平南县| 陆丰市| 鹿泉市| 泽普县| 龙陵县| 儋州市| 光山县| 兰西县| 昌吉市| 从江县| 五大连池市| 东乌珠穆沁旗|