tags:

views:

50

answers:

3

In Windows, is 0 valid PID for a process or is it reserved by OS? It would be nice if you can provide a link to a doc that says it is reserved or what. Thank!

+2  A: 

Open task manager - switch to the processes tab (maybe click "View", "Show columns" and enable the PID column).

PID 0 is the System Idle Process. Since that process isn't really a process and never exits, I suspect that it is always the case.

No documentation available to me, but I'm pretty certain this is always going to be the case.

developmentalinsanity
A: 

The PID of 0 is reserved for the Idle "psuedo-process", just like PID of 4 is reserved for the System (Windows Kernel).

I can't find any documentation on where that is specified, but querying the processes via any API (Perf Counters, WMI) will always give you the idle process for PID 0.

codekaizen
A: 

It's not stated anywhere but it comes down to how the kernel handle table works. This same object is used for both process handles and process/thread IDs. It happens that handle values all start at 0x4, and PsInitialSystemProcess is the first process to be created, so it gets a PID of 4. Idle process isn't actually a process and you can't open it. It probably doesn't have a PID for most intents and purposes but most tools consider it to be 0.

wj32