0
$\begingroup$

I'm a bit confused about kernel-threads, I searched a lot at the Internet, SOF and here but found very diverse and conflict answers. What is the need for Kernel threads? Are they threads that are only responsible for responding to system calls? Or they are threads that are encapsulating User threads and execute the user threads code? When there are X user threads and Y kernel threads in the System, can we say we have X + Y actual threads or only Y actual threads? When N user threads are mapped to a one kernel thread, does only one of these user thread are running and the others are waiting to execute?

$\endgroup$
1
1
$\begingroup$

What is the need for Kernel threads?

There is no need for Kernel threads. There are plenty of Operating Systems that don't have them and work just fine, so they are clearly not needed.

Are they threads that are only responsible for responding to system calls?

That depends on the specific Operating System, mostly. For some, the answer may be Yes, for others, the answer may be No.

Or they are threads that are encapsulating User threads and execute the user threads code?

That depends on the specific Operating System, mostly. For some, the answer may be Yes, for others, the answer may be No.

When there are X user threads and Y kernel threads in the System, can we say we have X + Y actual threads or only Y actual threads?

That depends on how, precisely, you define the terms "user threads", "kernel threads", and "actual threads".

When N user threads are mapped to a one kernel thread, does only one of these user thread are running and the others are waiting to execute?

Most likely, yes. However, in such a case, an N:1 threading model is uncommon. More common is an N:M threading model where N user threads are scheduled by a user space scheduler to M kernel threads (which are then, in turn, scheduled by the kernel scheduler).

Note that what is meant by the term "kernel thread" differs wildly between different OSs.

$\endgroup$
1
  • $\begingroup$ If there is no need for them then why there are OSes adopt and use them? Why the concept of the kernel threads came to existence in the first place? $\endgroup$
    – osama.bmaq
    Sep 9 at 20:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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