@@ -375,9 +375,8 @@ Glossary
375375 executed by multiple threads simultaneously. Critical sections are
376376 typically protected using :term: `locks <lock> ` or other
377377 :term: `synchronization primitives <synchronization primitive> ` to
378- ensure :term: `thread-safe ` access. In the C API, critical sections
379- on shared objects can be protected using :c:macro: `Py_BEGIN_CRITICAL_SECTION `
380- and :c:macro: `Py_END_CRITICAL_SECTION `. See also :term: `lock ` and
378+ ensure :term: `thread-safe ` access. Critical section are purely a concept
379+ in the C API and are not exposed in Python. See also :term: `lock ` and
381380 :term: `race condition `.
382381
383382 CPython
@@ -413,10 +412,11 @@ Glossary
413412 A situation where two or more threads are unable to proceed because
414413 each is waiting for the other to release a resource. For example,
415414 if thread A holds lock 1 and waits for lock 2, while thread B holds
416- lock 2 and waits for lock 1, both threads will wait indefinitely.
417- Deadlocks can be avoided by always acquiring multiple :term: `locks <lock> `
418- in a consistent order or by using timeout-based locking. See also
419- :term: `lock ` and :term: `reentrant `.
415+ lock 2 and waits for lock 1, both threads will wait indefinitely. Any
416+ program that makes blocking calls using more than one lock is possibly
417+ susceptible to deadlocks. Deadlocks can be avoided by always acquiring
418+ multiple :term: `locks <lock> ` in a consistent order or by using
419+ timeout-based locking. See also :term: `lock ` and :term: `reentrant `.
420420
421421 decorator
422422 A function returning another function, usually applied as a function
@@ -935,8 +935,10 @@ Glossary
935935 module provides :class: `~threading.Lock ` (a basic lock) and
936936 :class: `~threading.RLock ` (a :term: `reentrant ` lock). Locks are used
937937 to prevent :term: `race conditions <race condition> ` and ensure
938- :term: `thread-safe ` access to shared data. See also
939- :term: `critical section `, :term: `deadlock `, and :term: `reentrant `.
938+ :term: `thread-safe ` access to shared data. Alternative design patterns
939+ to locks exist such as queues, producer/consumer patterns, and
940+ thread-local state. See also :term: `critical section `, :term: `deadlock `,
941+ and :term: `reentrant `.
940942
941943 loader
942944 An object that loads a module.
@@ -1023,11 +1025,11 @@ Glossary
10231025 See :term: `method resolution order `.
10241026
10251027 mutable
1026- Mutable objects can change their value but keep their :func: ` id `.
1027- In multi-threaded programs, mutable objects that are shared between
1028- threads require careful synchronization to avoid :term: ` concurrent modification `
1029- issues. See also :term: `immutable `, :term: ` thread-safe `, and
1030- :term: `concurrent modification `.
1028+ An :term: ` object ` with state that is allowed to change during the course
1029+ of the program. In multi-threaded programs, mutable objects that are
1030+ shared between threads require careful synchronization to avoid
1031+ :term: ` concurrent modification ` issues. See also :term: `immutable `,
1032+ :term: `thread-safe `, and :term: ` concurrent modification `.
10311033
10321034 named tuple
10331035 The term "named tuple" applies to any type or class that inherits from
@@ -1100,8 +1102,7 @@ Glossary
11001102 the same inputs. In multi-threaded programs, non-deterministic behavior
11011103 often results from :term: `race conditions <race condition> ` where the
11021104 relative timing or interleaving of threads affects the result.
1103- :term: `Data races <data race> ` are a common cause of non-deterministic
1104- bugs. Proper synchronization using :term: `locks <lock> ` and other
1105+ Proper synchronization using :term: `locks <lock> ` and other
11051106 :term: `synchronization primitives <synchronization primitive> ` helps
11061107 ensure deterministic behavior.
11071108
@@ -1128,12 +1129,13 @@ Glossary
11281129
11291130 parallelism
11301131 The simultaneous execution of multiple operations on different CPU cores.
1131- True parallelism requires multiple processors or processor cores and
1132- allows operations to run at exactly the same time, not just interleaved.
1132+ True parallelism requires multiple processors or processor cores where
1133+ operations run at exactly the same time and are not just interleaved.
11331134 In Python, the :term: `free-threaded <free threading> ` build enables
1134- parallelism for multi-threaded programs by removing the :term: `global
1135- interpreter lock `. The :mod: `multiprocessing ` module also enables
1136- parallelism by using separate processes. See also :term: `concurrency `.
1135+ parallelism for multi-threaded programs that access state stored in the
1136+ interpreter by disabling the :term: `global interpreter lock `. The
1137+ :mod: `multiprocessing ` module also enables parallelism by using separate
1138+ processes. See also :term: `concurrency `.
11371139
11381140 parameter
11391141 A named entity in a :term: `function ` (or method) definition that
@@ -1221,13 +1223,10 @@ Glossary
12211223
12221224 per-module state
12231225 State that is stored separately for each instance of a module, rather
1224- than in :term: `global state `. For :term: `extension modules <extension module> `
1225- written in C, per-module state helps support multiple interpreters and
1226- is safer in :term: `free-threaded <free threading> ` builds because each
1227- module instance can have its own data without requiring global
1228- synchronization. Per-module state is accessed through the module object
1229- rather than through C static variables. See :ref: `isolating-extensions-howto `
1230- for more information. See also :term: `global state `.
1226+ than in :term: `global state `. Per-module state is accessed through the
1227+ module object rather than through C static variables.
1228+ See :ref: `isolating-extensions-howto ` for more information. See also
1229+ :term: `global state `.
12311230
12321231 PEP
12331232 Python Enhancement Proposal. A PEP is a design document
@@ -1320,7 +1319,7 @@ Glossary
13201319 'email.mime.text'
13211320
13221321 race condition
1323- A flaw in the design or implementation of a program where the correctness
1322+ A condition of a program where the its behavior
13241323 depends on the relative timing or ordering of events, particularly in
13251324 multi-threaded programs. Race conditions can lead to
13261325 :term: `non-deterministic ` behavior and bugs that are difficult to
@@ -1359,7 +1358,9 @@ Glossary
13591358
13601359 For functions, reentrancy means the function can be safely called again
13611360 before a previous invocation has completed, which is important when
1362- functions may be called recursively or from signal handlers.
1361+ functions may be called recursively or from signal handlers. Thread-unsafe
1362+ functions may be :term: `non-deterministic ` if they're called reentrantly in a
1363+ multithreaded program.
13631364
13641365 For locks, Python's :class: `threading.RLock ` (reentrant lock) is
13651366 reentrant, meaning a thread that already holds the lock can acquire it
@@ -1479,7 +1480,9 @@ Glossary
14791480 :mod: `threading ` module provides several synchronization primitives
14801481 including :class: `~threading.Lock `, :class: `~threading.RLock `,
14811482 :class: `~threading.Semaphore `, :class: `~threading.Condition `,
1482- :class: `~threading.Event `, and :class: `~threading.Barrier `. These
1483+ :class: `~threading.Event `, and :class: `~threading.Barrier `. Additionally,
1484+ the :mod: `queue ` module provides multi-producer, multi-consumer queues
1485+ that are especially usedul in multithreaded programs. These
14831486 primitives help prevent :term: `race conditions <race condition> ` and
14841487 coordinate thread execution. See also :term: `lock ` and
14851488 :term: `critical section `.
0 commit comments