What exactly is a kernel thread and how does it work with processes?
operating-system
Solution
Yes, kernel threads are quite similar to processes. In fact, modern operating systems blur the distinction between threads and processes. In Linux, the `clone` system call can be used to create a thread (same PID, same address space, same file descriptor table, etc.) or a process (distinct PID, etc.) or anything in between.
(FreeBSD has a similar system call called `rfork`, which generalizes `fork`. I think the idea of unifying threads and processes originated in Plan 9.)
Problem
From my understanding, a user thread is created by the user from library and managed in user space. A process can contain one or more user threads and the kernel is not aware of them. So what is a kernel thread? Are they similar to processes or are they contained in processes similar to user thread? Also, I saw diagrams of user threads mapping to kernel threads. How exactly does that work in terms of execution? Does the kernel schedule a kernel thread and execute the user threads mapped to that thread?