This series of articles prepared by Zhang tonghao, reproduced please note the Source: http://blog.csdn.net/muge0913/article/details/7480929
Email: muge0913@sina.com
Because the kernel does not distinguish between processes and threads, kernel threads are also called Kernel processes ). Note that threads in common processes cannot be considered as processes.
Differences between kernel threads and common processes:
1. the kernel thread runs only in the kernel state. Normal processes can run in the kernel state and user State.
2. the kernel thread can only call kernel functions. Common processes can call kernel functions through the system.
3. the kernel thread can only run in an address space greater than page_offset, while a common process can have 4 GB of address space (except for 3 GB of user space access, you can access 1 GB of kernel space through system calls ).
Because the kernel thread is not dragged down by the user context, it is often used by the kernel to execute some important tasks, such as refreshing the disk cache and switching different pages.
In Linux, run the PS-Ef command to see that the process ending with "D" is the kernel thread.
The kernel thread is created by kernel_thread in the kernel state.
In linux2.6.xxx/ARCH/ARM/include/ASM/processor. h/** create a new kernel thread */extern intkernel_thread (INT (* fN) (void *), void * Arg, unsigned long flags );
Parameter description:
FN: the function to be executed by the newly created kernel thread.
Arg: FN parameter.
Flags: similar to clone_flags in do_fork. In kernel_thread, do_fork uses clone_vm by default.