Kernel Learning: Kernel thread

Source: Internet
Author: User
Tags thread

Because the kernel does not differentiate between processes and threads, kernel threads (kernel thread) are also called kernel processes (kernel process). Note that threads in normal processes cannot be understood as processes.

The difference between a kernel thread and a normal process:

1, the kernel thread only runs in the kernel state, the ordinary process can run in the kernel state and the user state.

2, the kernel thread can only call kernel functions, the normal process can call the kernel function through system calls.

3, the kernel thread can only run in the address space greater than page_offset, and the ordinary process can 4G address space (in addition to access to user space 3G, through system calls can access the kernel space 1G space).

Because kernel threads are not dragged by the user state context, they are often used by the kernel to perform important tasks such as refreshing the disk cache and exchanging different pages.

A process with the end of "D" seen in a Linux system with the PS–EF command is the kernel thread.

Kernel threads are 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.

The ARG:FN parameters.

Flags: Similar to the role of Clone_flags in Do_fork. The CLONE_VM is used by default in Kernel_thread Do_fork.

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/OS/unix/

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.