简体   繁体   中英

Process in Linux Kernel space

In user-space we can create a process by executing program or calling fork inside a program, Kernel will create process descriptor(task_struct) for each user-space process.

In kernel space is there any any concept called process, if so how they will be created?

As per my understanding kernel threads will be created in kernel space using kernel_thread() etc, kernel_thread() is internally calling do_fork() , so kernel threads also represented using task_struct ?

If both user-space process and kernel space threads are represented using task_struct , then how scheduler will schedule the user-space process and kernel space thread?

Yes, they all handled through task_struct .

Critical kernel threads have RT ("Real-Time") scheduler class which have priority over CFS scheduler that is usually used for user-space threads. . Just check your ps:

# ps ax --format uname,pid,ppid,tty,cmd,cls,pri,rtprio | egrep '(FF|RR)'

(kernel threads are shown in square brackets)

However, as you can see many kernel threads have TS scheduler. I do not think that there is reason make all kernel threads realtime. For example, you can defer writeback to a disk over emotional scene shown by VLC player.

而且我想即使是与另一个线程共享内存段(例如,堆,全局varaibales)的POSIX线程,也都由task_struct处理。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM