Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Process identifier

From Wikipedia, the free encyclopedia
(Redirected fromProcess ID)
Number used by operating system kernels to identify an active process
icon
This articleneeds additional citations forverification. Please helpimprove this article byadding citations to reliable sources. Unsourced material may be challenged and removed.
Find sources: "Process identifier" – news ·newspapers ·books ·scholar ·JSTOR
(October 2017) (Learn how and when to remove this message)

Incomputing, theprocess identifier (a.k.a.process ID orPID) is a number used by mostoperating systemkernels—such as those ofUnix,macOS andWindows—to uniquely identify an activeprocess. This number may be used as a parameter in various function calls, allowing processes to be manipulated, such as adjusting the process's priority orkilling it altogether.

Unix-like

[edit]

InUnix-like operating systems, new processes are created by thefork()system call. The PID is returned to theparent process, enabling it to refer to the child in further function calls. The parent may, for example, wait for the child to terminate with thewaitpid() function, or terminate the process withkill().

There are two tasks with specially distinguished process IDs: PID 0 is used forswapper orsched, which is part of the kernel and is a process that runs on a CPU core whenever that CPU core has nothing else to do.[1] Linux also calls the threads of this processidle tasks.[2] In some APIs, PID 0 is also used as a special value that always refers to the calling thread, process, or process group.[3][4] Process ID 1 is usually theinit 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.

Process IDs, in the first place, are usually allocated on a sequential basis,[5] beginning at 0 and rising to a maximum value which varies from system to system. Once this limit is reached, allocation restarts at 300 and again increases. InmacOS andHP-UX, allocation restarts at 100.[6] However, for this and subsequent passes any PIDs still assigned to processes are skipped. Some consider this to be a potential security vulnerability in that it allows information about the system to be extracted, or messages to be covertly passed between processes. As such, implementations that are particularly concerned about security may choose a different method of PID assignment.[7] On some systems, likeMPE/iX, the lowest available PID is used, sometimes in an effort to minimize the number of process information kernel pages in memory.

The current process ID is provided by agetpid() system call,[8] or as a variable$$ in shell. The process ID of a parent process is obtainable by agetppid() system call.[9]

OnLinux, the maximum process ID is given by the pseudo-file/proc/sys/kernel/pid_max.[10]pid_max has historically been set to 65,535 (2161{\displaystyle 2^{16}-1}) on Linux, but can now be configured to up to 4,194,303 (2221{\displaystyle 2^{22}-1}) on 64-bit Linux systems,[11]

Pidfile

[edit]

Some processes, for example, themoc music player and theMySQL daemon, write their PID to a documented file location, to allow other processes to look it up.[citation needed]

Microsoft Windows

[edit]

On theWindows family of operating systems, one can get the current process's ID using theGetCurrentProcessId() function of theWindows API,[12] and ID of other processes usingGetProcessId().[13] Internally, process ID is called aclient ID, and is allocated from the same namespace asthread IDs, so these two never overlap. TheSystem Idle Process is given process ID 0. TheSystem Process is given the process ID 8 onWindows 2000 and 4 onWindows XP andWindows Server 2003.[14] On theWindows NT family of operating systems, process and thread identifiers are all multiples of 4, but it is not part of the specification.[15]

See also

[edit]

References

[edit]
  1. ^Anderson, David (2024-06-05),What is PID 0?, archived fromthe original on 2024-06-07
  2. ^Linux kernel code: tools/perf/builtin-sched.c,pid 0 == swapper == idle task
  3. ^kill(2) — Linux manual page
  4. ^sched_setscheduler(2) — Linux manual page
  5. ^pid_namespaces(7) — Linux manual page
  6. ^"What's the maximum pid for Mac OS X?".Ask Different. Retrieved2024-11-02.
  7. ^comp.unix.aix Frequently Asked Questions, retrieved2008-07-21
  8. ^"getpid",The Open Group Base Specifications Issue 7, 2018 edition
  9. ^"getppid",The Open Group Base Specifications Issue 7, 2018 edition
  10. ^"proc - process information pseudo-filesystem",Linux Programmer's Manual, retrieved2009-12-28
  11. ^"Linux To Allow Adjusting pid_max Per PID Namespace - Helping Old Software".www.phoronix.com. Retrieved2025-12-11.
  12. ^"GetCurrentProcessId Function",Windows Dev Center,Microsoft, 5 December 2018
  13. ^"GetProcessId function",Windows Dev Center,Microsoft, 5 December 2018
  14. ^Russinovich, Mark; David A. Solomon (2005), "Chapter 2: System Architecture",Microsoft Windows Internals (4th ed.), Microsoft Press, p. 76,ISBN 0-7356-1917-4
  15. ^Chen, Raymond (2008-02-28),"Why are process and thread IDs multiples of four?",The Old New Thing,Microsoft
Retrieved from "https://en.wikipedia.org/w/index.php?title=Process_identifier&oldid=1337218009"
Category:
Hidden categories:

[8]ページ先頭

©2009-2026 Movatter.jp