1

I read some pthread-related blogs, they all mentioned the concepts of kernel thread and user thread, but did not provide demo code.

Is the thread created by the pthread_create function of pthread a kernel thread?

How can I create a user-space thread?

aszswaz
  • 609
  • 3
  • 10
  • The question is unclear. There are three types of threads: 1. Threads that run in kernel space, and 2. Threads that run in userspace, but that are managed by the kernel, and 3. Threads that run in userspace and that are also managed entirely in userspace (so that the kernel is unaware of them, because they are not kernel objects). Threads of type #1 are always called kernel threads and threads of type #3 are always called user threads. Threads of type #2 are called user threads when distinguishing them from type #1, but they are called kernel threads when distinguishing them from type #3. – Andreas Wenzel Oct 23 '21 at 17:11
  • When you call `pthread_create`, you are normally creating a thread of type #2. I am not sure if some POSIX implementations implement pthreads with threads of type #3. – Andreas Wenzel Oct 23 '21 at 17:15

0 Answers0