5

As we all know, kthreadd is a kernel thread, which is used to help others create new kernel threads (Review kthread_create_list to see if there is any new kernel thread need to create).

But I can not understand why we do not use create_kthread to create a new kernel thread? I do not see any difference kthreadd makes.

Could you give me some suggestions, please.

Thanks for your great help.

1
  • My guess (hence not writing it as an answer) would be that, since thread creation can be a lengthy process, the kernel just queues up thread creation requests for kthreadd to handle "later" so that the kernel itself can move on to something else - leading to lower overall latency and better performance.
    – twalberg
    Nov 15, 2012 at 15:14

1 Answer 1

2

Not Really. kthreadd is a daemon thread that runs in kernel space. The reason is that kernel needs to some times create threads but creating thread in kernel is very tricky. Hence kthreadd is a thread that kernel uses to spawn newer threads if required from there . This thread can access userspace address space also but should not do so . Its managed by kernel so one need not worry.

1
  • My opinion: TO create a new thread in kernel, many shared object resources needed to modified. Normal kernel threads may also directly call the kernel_thread function to create threads, however, this may cause many many writer to the global shared resource and hence slow down the creating performance when in heavy load.
    – Houcheng
    Feb 26, 2013 at 6:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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