Skip to content

Conversation

@corona10
Copy link
Member

@corona10 corona10 commented Oct 10, 2023

PyThreadState* last_holder;
/* Whether the GIL is already taken (-1 if uninitialized). This is
atomic because it can be read without any lock taken in ceval.c. */
_Py_atomic_int locked;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vstinner @colesbury

return (_Py_atomic_load_explicit(&gil->locked, _Py_memory_order_acquire) >= 0);

_Py_atomic_store_explicit(&gil->locked, 0, _Py_memory_order_release);

IIUC, To update locked field we need to introduce _Py_atomic_load/store_int_release/acquire

Do you have better ideas?

Copy link
Member

@vstinner vstinner Oct 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It sounds like a good idea, for another API

EDIT: Oops, I wrote PEP not API, sorry about that :-D Need more coffee.

Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@corona10 corona10 merged commit 2566434 into python:main Oct 13, 2023
@corona10 corona10 deleted the gh-109693-gil branch October 13, 2023 01:07
Glyphack pushed a commit to Glyphack/cpython that referenced this pull request Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants