- Mastering Linux Kernel Development
- Raghu Bharadwaj
- 277字
- 2021-07-08 09:47:19
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.
- Unity 2020 By Example
- Git Version Control Cookbook
- 復雜軟件設計之道:領域驅動設計全面解析與實戰
- Visual Basic 6.0程序設計計算機組裝與維修
- Learning Flask Framework
- DevOps Automation Cookbook
- 前端架構:從入門到微前端
- 從零開始學C語言
- 從零開始:UI圖標設計與制作(第3版)
- SciPy Recipes
- JavaScript+jQuery網頁特效設計任務驅動教程
- 并行編程方法與優化實踐
- Android開發進階實戰:拓展與提升
- HTML 5與CSS 3權威指南(第4版·上冊)
- Struts2技術內幕:深入解析Struts架構設計與實現原理