Linux - KernelThis forum is for all discussion relating to the Linux kernel.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I remember that I saw somewhere a parameter to define the minimum PID value for user processes, which means any PID that is below that is a kernel process.
The thing is, I don't remember where... was it in my kernel config?
How to read and define this value?
you'll realize all the first (small) PIDS are kernel processes.
You can e.g. guess that if PID < 300, this is a kernel process, so you'd better not try to kill it!
The thing is, this is not always 300 and this number can be configured (and read). I just don't remember where.
you'll realize all the first (small) PIDS are kernel processes.
As to unique identifiers in kernels up to 2.6.18 (RHEL version w backports), what these processes have in common is all kernel threads share the same user Id (obviously 0) and the same session Id and process group Id. What's more is that, depending on the machines HW, "kthread" spawns a host of children which then share the common "kthread" ancestors identifiers.
Quote:
Originally Posted by MisterBark
The thing is, this is not always 300 and this number can be configured (and read). I just don't remember where.
There is a "RESERVED_PIDS" with default value of 300 in kernel/pid.c (2.6.29 - 3.4: http://lxr.free-electrons.com/source...pid.c?v=2.6.29) but if you would run a '\ps axfo pid,ppid,pgid,sid,sess,uid,cmd --sort=pid' then you see no artificial limit is posed.
I'll move this thread out of the Linux Security forum to the Kernel forum as this in no way is related to Linux Security.
Next time please give a wee bit more thought to where you post, TIA.
There is a "RESERVED_PIDS" with default value of 300 in kernel/pid.c (2.6.29 - 3.4: http://lxr.free-electrons.com/source...pid.c?v=2.6.29) but if you would run a '\ps axfo pid,ppid,pgid,sid,sess,uid,cmd --sort=pid' then you see no artificial limit is posed.
PID #1 (init) is hard-coded. This process-table entry is constructed "by hand" during kernel initialization, and this very special process cannot die. (If it does, the kernel panics.)
Some operating systems have several such "hand built" entries, and the definition and purpose of these special processes vary from system to system.
"Kernel threads" are parts of the operating system kernel that are need to operate in an asynchronous fashion. (For instance, kswapd needs to perform disk I/O and to wait for completion of those I/O operations.) They are nevertheless "fully part of the kernel" and as such they operate by special rules. They will typically have low-numbered PIDs although there are no fixed assignments.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.