summaryrefslogtreecommitdiffstats
path: root/Doc/library/os.rst
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2023-10-02 15:47:57 (GMT)
committerGitHub <noreply@github.com>2023-10-02 15:47:57 (GMT)
commit5245b97e132ae071e2b574224e0788cab62fdcc9 (patch)
tree69593a02dda9840e8bbc8d706a2f1a51722cee4d /Doc/library/os.rst
parentce332aa8c5c2d3a086cabb3f21d2da3a96e78680 (diff)
downloadcpython-5245b97e132ae071e2b574224e0788cab62fdcc9.zip
cpython-5245b97e132ae071e2b574224e0788cab62fdcc9.tar.gz
cpython-5245b97e132ae071e2b574224e0788cab62fdcc9.tar.bz2
[3.12] gh-109649: Enhance os.cpu_count() documentation (#110169)
* gh-109649: Enhance os.cpu_count() documentation * Doc: Specify that os.cpu_count() counts *logicial* CPUs. * Doc: Specify that os.sched_getaffinity(0) is related to the calling thread. * Fix test_posix.test_sched_getaffinity(): restore the old CPU mask when the test completes! * Restore removed text
Diffstat (limited to 'Doc/library/os.rst')
-rw-r--r--Doc/library/os.rst16
1 files changed, 9 insertions, 7 deletions
diff --git a/Doc/library/os.rst b/Doc/library/os.rst
index 4ffd520..0c36c24 100644
--- a/Doc/library/os.rst
+++ b/Doc/library/os.rst
@@ -5141,8 +5141,10 @@ operating system.
.. function:: sched_getaffinity(pid, /)
- Return the set of CPUs the process with PID *pid* (or the current process
- if zero) is restricted to.
+ Return the set of CPUs the process with PID *pid* is restricted to.
+
+ If *pid* is zero, return the set of CPUs the calling thread of the current
+ process is restricted to.
.. _os-path:
@@ -5183,12 +5185,12 @@ Miscellaneous System Information
.. function:: cpu_count()
- Return the number of CPUs in the system. Returns ``None`` if undetermined.
-
- This number is not equivalent to the number of CPUs the current process can
- use. The number of usable CPUs can be obtained with
- ``len(os.sched_getaffinity(0))``
+ Return the number of logical CPUs in the system. Returns ``None`` if
+ undetermined.
+ This number is not equivalent to the number of logical CPUs the current
+ process can use. ``len(os.sched_getaffinity(0))`` gets the number of logical
+ CPUs the calling thread of the current process is restricted to
.. versionadded:: 3.4