-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
gh-109693: Update _gil_runtime_state.last_holder to use pyatomic.h #110605
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
corona10
commented
Oct 10, 2023
•
edited by bedevere-app
bot
Loading
edited by bedevere-app
bot
- Issue: Clean-up pyatomic headers #109693
@@ -25,7 +25,7 @@ struct _gil_runtime_state { | |||
unsigned long interval; | |||
/* Last PyThreadState holding / having held the GIL. This helps us | |||
know whether anyone else was scheduled after we dropped the GIL. */ | |||
_Py_atomic_address last_holder; | |||
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line 179 in 982f1b7
return (_Py_atomic_load_explicit(&gil->locked, _Py_memory_order_acquire) >= 0); |
Line 194 in 982f1b7
_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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.