What is a Kernel thread?

后端 未结 4 877
走了就别回头了
走了就别回头了 2020-12-23 10:16

i am just started coding of device driver and new to threading, went through many documents for getting an idea about threads. i still have some doubts.

4条回答
  •  猫巷女王i
    2020-12-23 10:38

    1. A kernel thread is a task_struct with no userspace components.
    2. Beside from the lack of userspace, it has different ancestors (kthreadd kernel thread instead of the init process) and is created by a kernel-only API instead of sequences of clone of fork/exec system calls.
    3. Two kernel thread have kthreadd as a parent. Apart from that, kernel thread enjoy the same "independence" one from another as userspace processes.
    4. Use the kthread_run function/macro from the kthread.h header You will most probably have to write a kernel module in order to call this function, so you should take a look a the Linux Device Drivers
    5. If you are referring to the text output of your implementation (via printk calls), you can see this output in the kernel log using the dmesg command.

提交回复
热议问题