Kernel and user threads

Jyothi
2 min readJun 10, 2024

--

A kernel thread is a kernel entity, like processes and interrupt handlers; it is the entity handled by the system scheduler. A kernel thread runs within a process, but can be referenced by any other thread in the system. The programmer has no direct control over these threads.

A user thread is an entity programmers use to handle multiple flows of controls within a program. The threads library provides the API for handling user threads. A user thread only exists within a process; a user thread in process A cannot reference a user thread in process B. The library uses a proprietary interface to handle kernel threads for executing user threads.

User threads are mapped to kernel threads by the threads library. The way this mapping is done is called the thread model. There are three possible thread models: M:1 model, 1:1 model, M:N model.

As per IBM documentation of AIX, the mapping of user threads to kernel threads is done using virtual processors. A virtual processor (VP) is a library entity that is usually implicit. For a user thread, the VP behaves like a CPU. In the library, the VP is a kernel thread or a structure bound to a kernel thread.

In the M:1 model, all user threads are mapped to one kernel thread; all user threads run on one VP. In the 1:1 model, each user thread is mapped to one kernel thread; each user thread runs on one VP. In the M:N model, all user threads are mapped to a pool of kernel threads; all user threads run on a pool of virtual processors. A user thread may be bound to a specific VP, as in the 1:1 model. All unbound user threads share the remaining VPs. This is the most efficient and most complex thread model.

This is from IBM documentation.

--

--

No responses yet