gh-111569: Implement Python critical section API (gh-111571)

Critical sections are helpers to replace the global interpreter lock
with finer grained locking.  They provide similar guarantees to the GIL
and avoid the deadlock risk that plain locking involves.  Critical
sections are implicitly ended whenever the GIL would be released.  They
are resumed when the GIL would be acquired.  Nested critical sections
behave as if the sections were interleaved.
This commit is contained in:
Sam Gross 2023-11-08 17:39:29 -05:00 committed by GitHub
parent 0b718e6407
commit 31c90d5838
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 630 additions and 7 deletions

View file

@ -2371,7 +2371,7 @@ new_reference(PyObject *op)
#else
op->ob_tid = _Py_ThreadId();
op->_padding = 0;
op->ob_mutex = 0;
op->ob_mutex = (struct _PyMutex){ 0 };
op->ob_gc_bits = 0;
op->ob_ref_local = 1;
op->ob_ref_shared = 0;