Exploring kernel-kernel threads

Source: Internet
Author: User

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.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.