Multithreading can be supported at the Operating System level (kernel-level threads), at the application level (user-level threads) or simultaneously at both levels.
-
User-level threads are much more efficient than kernel level threads. They don't require any OS support, so a given user-level thread package can be portable between different machines and Os'. The weakness of user-level threads is a possibility that a thread which blocks on a system call will eventually block the whole process. To avoid that user-level thread translate blocking system calls into non-blocking ones.
-
Kernel-level threads have the advantage that when a thread blocks on a system call, the Operating System, aware of that, can schedule another processes' thread to run. Those threads can also be scheduled on different processors (when the hardware offers more than one CPU) in a transparent to an application fashion. The main disadvantage of the kernel-level threads is their poor efficiency -- order of magnitude slower than user-level counterparts.
|