Introduction A thread is the smallest unit of CPU utilization within a process, comprising its own program counter, register set and stack space, but sharing the process’s code, data and OS resources. Threads enable parallelism and better resource utilization. Based on where threads are managed, they are classified into User-Level Threads (ULTs) and Kernel-Level Threads (KLTs).
clone(), CreateThread()).| Aspect | User-Level Threads | Kernel-Level Threads |
|---|---|---|
| Management | Thread library in user space | OS kernel |
| Creation/Destroy | Very fast (function calls) | Slower (system calls) |
| Context Switch | Cheap (no mode switch) | Expensive (user ↔ kernel mode switch) |
| Blocking | Entire process blocks on one thread’s I/O | Only the blocked thread sleeps; others continue |
| Concurrency | No true parallelism on multiprocessors | True parallelism on multiple CPUs |
| Scheduling | Library-defined (cooperative or timer-driven) | Kernel-defined (preemptive, priorities) |
| Portability | High (library-based) | Depends on OS support and versions |