summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorSam Gross <colesbury@gmail.com>2024-02-09 22:08:32 (GMT)
committerGitHub <noreply@github.com>2024-02-09 22:08:32 (GMT)
commita3af3cb4f424034b56404704fdf8f18e8c0a9982 (patch)
tree62ee00ea8725669a67c0fb9f7d8692fedf55bbae /Modules
parenta225520af941fb125a4ede77a617501dfb8b46da (diff)
downloadcpython-a3af3cb4f424034b56404704fdf8f18e8c0a9982.zip
cpython-a3af3cb4f424034b56404704fdf8f18e8c0a9982.tar.gz
cpython-a3af3cb4f424034b56404704fdf8f18e8c0a9982.tar.bz2
gh-110481: Implement inter-thread queue for biased reference counting (#114824)
Biased reference counting maintains two refcount fields in each object: `ob_ref_local` and `ob_ref_shared`. The true refcount is the sum of these two fields. In some cases, when refcounting operations are split across threads, the ob_ref_shared field can be negative (although the total refcount must be at least zero). In this case, the thread that decremented the refcount requests that the owning thread give up ownership and merge the refcount fields.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/posixmodule.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index e26265f..230c961 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -637,6 +637,10 @@ PyOS_AfterFork_Child(void)
tstate->native_thread_id = PyThread_get_thread_native_id();
#endif
+#ifdef Py_GIL_DISABLED
+ _Py_brc_after_fork(tstate->interp);
+#endif
+
status = _PyEval_ReInitThreads(tstate);
if (_PyStatus_EXCEPTION(status)) {
goto fatal_error;