Search code examples
pthreadsclone

Kernel Level and User Level Threads


Clone (Linux) creates a kernel level thread while PThreads creates a user level thread. I have the feeling that some OSs does not actually support the user level threads. As an example: On a dual core processor, if I have 2 running processes where the first one has 3 threads and the second one has 4 threads, then the time slots of the CPU won't be divided into 7 equal slots each to a single thread BUT one core will be allotted to process 1 and shared among its 3 threads, while the other core will be allotted to process 2 and shared among its 4 threads.

While if we use clone (on linux) rather than PThreads. Then the time of the dual core processor will be shared equally across the different kernel threads (7).

Is this TRUE?


Solution

  • Here is a description of the NPTL library most commonly used today:

    NPTL is a so-called 1×1 threads library, in that threads created by the user (via the pthread_create() library function) are in 1-1 correspondence with schedulable entities in the kernel (tasks, in the Linux case). This is the simplest possible threading implementation.

    If they are schedulable entities by the kernel, then they can be scheduled individually on any processor, and your statement is not true.