Which process has PID 0?

I’m looking for the process started in Linux which has process ID 0. I know init has PID 1 , which is the first process in Linux, is there any process with PID 0?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

From the wikipedia page titled: Process identifier:

There are two tasks with specially distinguished process IDs: swapper
or sched has process ID 0 and is responsible for paging, and is
actually part of the kernel rather than a normal user-mode process.
Process ID 1 is usually the init process primarily responsible for
starting and shutting down the system. Originally, process ID 1 was
not specifically reserved for init by any technical measures: it
simply had this ID as a natural consequence of being the first process
invoked by the kernel. More recent Unix systems typically have
additional kernel components visible as ‘processes’, in which case PID
1 is actively reserved for the init process to maintain consistency
with older systems.

You can see the evidence of this if you look at the parent PIDs (PPID) of init and kthreadd:

$ ps -eaf
UID        PID  PPID  C STIME TTY          TIME CMD
root         1     0  0 Jun24 ?        00:00:02 /sbin/init
root         2     0  0 Jun24 ?        00:00:00 [kthreadd]

kthreadd is the kernel thread daemon. All kthreads are forked from this thread. You can see evidence of this if you look at other processes using ps and seeing who their PPID is:

$ ps -eaf
root         3     2  0 Jun24 ?        00:00:57 [ksoftirqd/0]
root         4     2  0 Jun24 ?        00:01:19 [migration/0]
root         5     2  0 Jun24 ?        00:00:00 [watchdog/0]
root        15     2  0 Jun24 ?        00:01:28 [events/0]
root        19     2  0 Jun24 ?        00:00:00 [cpuset]
root        20     2  0 Jun24 ?        00:00:00 [khelper]

Notice they’re all 2.

Method 2

From Process Identifier wiki:

There are two tasks with specially distinguished process IDs: swapper
or sched has process ID 0 and is responsible for paging, and is
actually part of the kernel rather than a normal user-mode process.

Method 3

The process with pid 0 is the scheduler,

Process ID Description:
0 The Scheduler
1 The init process
2 kflushd
3 kupdate
4 kpiod
5 kswapd
6 mdrecoveryd


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x