runasservice
Goto Top

Prozess-ID im Task-Manager

Hallo,

eine Frage in die Runde, weiß jemand zufällig warum die Prozess-ID (PID) unter Windows immer ein Vielfaches von 4 ist (0, 4, 8, 12, 16, 20 usw.) ?
Wurde das willkürlich von Microsoft festgelegt oder gibt dafür eine Logik?


MfG

Content-Key: 352704

Url: https://administrator.de/contentid/352704

Printed on: April 18, 2024 at 11:04 o'clock

Member: Kraemer
Kraemer Oct 24, 2017 at 12:54:30 (UTC)
Goto Top
Moin,

die PID ist vom Typ DWORD

Gruß
Member: emeriks
emeriks Oct 24, 2017 updated at 14:45:17 (UTC)
Goto Top
Hi,
Zitat von @Kraemer:
die PID ist vom Typ DWORD
Und? Das hat welchen Bezug auf die Frage?

Es ist mir bisher noch gar nicht aufgefallen, dass diese ID's je ein Vielfaches von 4 sind. Ich könnte mir vorstellen, dass das mit der internen Struktur zu tun hat, mit welcher solche Prozesse erzeugt und kontrolliert werden. Also mutmaßlich, dass Windows je Benutzerprozess intern 3 Steuerprozesse erzeugt, welche aber in der Taskliste nicht erscheinen.
Vielleicht kann man das ja im Procmon sehen.

E.
Member: AndreasHoster
Solution AndreasHoster Oct 25, 2017 at 07:38:59 (UTC)
Goto Top
Kurze Google Suche findet:
https://blogs.msdn.microsoft.com/oldnewthing/20080228-00/?p=23283

Auszug:
Process and thread IDs are multiples of four as a side-effect of code re-use. The same code the allocates kernel handles is also used to allocate process and thread IDs. Since kernel handles are a multiple of four, so too are process and thread IDs. This is an implementation detail, so don't write code that relies on it. I'm just telling you to satify your curiosity.

Und hier der Link warum Kernel Handles immer ein vielfaches von 4 sind:
https://blogs.msdn.microsoft.com/oldnewthing/20050121-00/?p=36633/

Auszug:
The availability of the bottom two bits is buried in the ntdef.h header file:
Low order two bits of a handle are ignored by the system and available
for use by application code as tag bits. The remaining bits are opaque
and used to store a serial number and table index.
//

#define OBJ_HANDLE_TAGBITS 0x00000003L