From this answer - software threads vs hardware threads, software threads are threads managed by OS. But I also learn another term called user threads, which are threads that's not kernel threads, i.e. the OS won't know about these threads. So does software threads include user threads?

I didn't get any answer from stackoverflow, but I think the idea is the same in the context of Linux, I'm asking about the term used in Linux, thanks.

For reference, I found an useful resource on Quora.

  • Why do you make the assumption that the OS does not know about 'user threads'? If I run ps, my OS shows me information about user threads/processes. I believe you are confusing threads with kernelspace/userspace. – Panki Dec 6 at 7:33
  • @Panki: Why do you make the assumption that the OS does not know about 'user threads'? it's from a book I read, and it says in case of many to one model, OS only knows the "one" part, and don't about the "many" part. – ptr_user7813604 Dec 6 at 7:35
  • @ptr_user7813604 You ask this question with the assumption that the OS can't see user processes, which is wrong. Hardware threads refers to the "physical" threads your CPU can execute in parallel. So yes, software threads include userland processes. – Panki Dec 6 at 7:41
  • @StephenKitt: Sorry sir, it's not in english, I'm not english learner. – ptr_user7813604 Dec 6 at 7:48
  • 2
    @Panki some userspace threading models are invisible to the kernel (they use an in-process scheduler). – Stephen Kitt Dec 6 at 7:48
up vote 1 down vote accepted

This is an area where terms tend to be overloaded — the same term is used with different meanings depending on the context. It’s not helped by the fact that the meaning commonly associated with various terms changes over time, so the age of the texts you’re reading is important.

There are a number of aspects to distinguish, or at least, two main ones.

  • User v. kernel threads can refer either to the execution context, or the management context. “Kernel threads” in Linux usually refers to the former: a kernel thread is a thread run in the kernel, for the kernel’s purposes (in ps, you’ll see them as processes with names in square brackets, e.g. [kthreadd], [khugepaged]...).
  • As mentioned in the SO answer, software v. hardware threads refers to the nature of the threads being discussed. In both cases, the concept of a thread is the idea of running multiple threads of execution in parallel. In the software sense, it’s a light-weight process; in the hardware sense, it’s a “light-weight” CPU (in Intel parlance, a hyperthread).

The “user threads” you’re referring to are typically known as green threads. They are software threads managed in userspace, with no kernel involvement. As with many concepts which are implemented in the kernel and in userspace, their use evolves over time as the perception of costs moves: in the past, and on other operating systems, threads weren’t well supported by the kernel, so they were implemented in user space; then kernels improved, and software started using kernel threads; then new environments considered kernel threads to be too expensive, and so it goes.

To answer your question, since user threads are software threads, the term “software threads” includes them.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.