Native POSIX Thread Library: Difference between revisions

Content deleted Content added
Design: struct task_struct
Line 19:
NPTL uses a similar approach to LinuxThreads, in that the primary abstraction known by the kernel is still a process, and new threads are created with the clone() [[system call]] (called from the NPTL library). However, NPTL requires specialized kernel support to implement (for example) the contended case of synchronisation primitives which might require threads to sleep and wake again. The primitive used for this is known as a [[futex]].
 
NPTL is a so-called 1×1 threads library, in that threads created by the user (via the <code>pthread_create()</code> library function) are in 1-1 correspondence with schedulable entities in the kernel (processestasks, in the Linux case). This is the simplest possible threading implementation.
 
An alternative to NPTL's 1×1 model is the ''m×n'' model where there are typically more userland threads than schedulable entities. In the ''m×n'' implementation, the threading library is responsible for scheduling user threads on the available schedulable entities; this makes [[context switch]]ing of [[Thread (computer science)|threads]] very fast, as it avoids system calls. However, this increases complexity and the likelihood of [[priority inversion]], as well as suboptimal scheduling without extensive (and expensive) coordination between the userland scheduler and the kernel scheduler.