Qual processo tem PID 0?

51

Estou procurando o processo iniciado no Linux que possui o ID do processo 0. Sei que init tem o PID 1, que é o primeiro processo no Linux, existe algum processo com PID 0?

    
por user9744 17.07.2013 / 06:01

3 respostas

49

Na página da Wikipédia intitulada: Identificador do processo :

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.

Você pode ver a evidência disso se observar os PIDs pai (PPID) de init e 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 é o daemon de encadeamento do kernel. Todos os kthreads são bifurcados deste tópico. Você pode ver evidências disso se você olhar para outros processos usando ps e ver quem é seu PPID:

$ 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]

Observe que eles são todos 2 .

    
por 17.07.2013 / 06:12
10

Do Identificador do Processo 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.

    
por 17.07.2013 / 06:12
4

O processo com pid 0 é o agendador,

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

    
por 20.07.2014 / 17:27

Tags