AbhinavChoudhury
AbhinavChoudhury

Reputation: 1187

Mapping User-level threads and Kernel-level threads

How are User-level threads mapped to Kernel-level threads?

Upvotes: 2

Views: 3086

Answers (2)

Chandan
Chandan

Reputation: 627

There's a bit of confusion about the terminology used for referring to ULTs and KLTs. Following are the two different interpretations. Please correct me if I got this wrong:

  1. KLTs are needed to achieve concurrency in the kernel (Note the interpretation of Kernel as a Process or a live entity). This is true about Micro kernels like Symbian, where a kernel thread is responsible for every hardware resource of the system (e.g File Server, Location Server, Calendar Server, etc). However, in a kernel like Linux, which is mostly a library (and not a process or a living entity on its own), there's really no meaning for Kernel threads. In Linux, every thread you create is treated by the Kernel as a process and Kernel always runs either in the Process context or the Interrupt context.

  2. Second interpretation is based on whether Threading (or concurrency) is visible to the Kernel or not. For instance, using setjmp, longjmp one can achieve concurrency at user space. Like already discussed, Kernel is totally unaware of this. This concurrency may be termed as ULT. And the thread whose creation the Kernel is aware of (one using Clone() system call) may be called KLT.

Upvotes: 0

David Schwartz
David Schwartz

Reputation: 182759

It varies by implementation. The three most common threading models are:

  1. 1-to-1: Each user-level thread has a corresponding entity that is scheduled by the kernel.

  2. n-to-1: Each process is scheduled by the kernel. Thread scheduling takes place entirely in user space.

  3. n-to-m: Each process has a pool of entities that are scheduled by the kernel. These are assigned to run particular user-level threads by a user-space scheduler that is part of the process.

Modern implementations are almost all 1-to-1.

Upvotes: 1

Related Questions