Implementing threads in the kernel

The entire kernel is a process with a lot of system (kernel) threads running in its context. The kernel has a thread table that keeps track of all the threads in the system.

The kernel maintains the traditional process table to keep track of processes. Function calls that can block a thread are executed as system calls, at much greater cost than the executing system procedure. When a thread blocks, the kernel must run another thread. When a thread is destroyed, it is marked as not runnable—but its kernel data structures are not otherwise affected. Afterwards, when a new thread needs to be created, an old thread is reactivated, recycling resources for usage. Thread recycling is also possible for user-level threads, ...

Get C++ Multithreading Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.