-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
parking_lot.c should use _PyTime_GetMonotonicClock() when available #112606
Closed
Tracked by
#108219
Labels
Comments
colesbury
added
type-bug
An unexpected behavior, bug, or error
3.13
bugs and security fixes
topic-free-threading
labels
Dec 1, 2023
This was referenced Dec 1, 2023
This was referenced Dec 2, 2023
Splitting into two PRs for |
corona10
pushed a commit
that referenced
this issue
Dec 6, 2023
As someone writes a fix for the mutex, ping me, I can review it ;-) |
erlend-aasland
pushed a commit
that referenced
this issue
Jan 30, 2024
…when available (#112616) Add a configure define for HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE_NP and replaces pthread_cond_timedwait() with pthread_cond_timedwait_relative_np() for relative time when supported in semaphore waiting logic.
aisk
pushed a commit
to aisk/cpython
that referenced
this issue
Feb 11, 2024
… in parking_lot.c (pythongh-112733)
aisk
pushed a commit
to aisk/cpython
that referenced
this issue
Feb 11, 2024
…lot.c when available (python#112616) Add a configure define for HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE_NP and replaces pthread_cond_timedwait() with pthread_cond_timedwait_relative_np() for relative time when supported in semaphore waiting logic.
Glyphack
pushed a commit
to Glyphack/cpython
that referenced
this issue
Sep 2, 2024
… in parking_lot.c (pythongh-112733)
Closing this as the relevant PRs landed a while ago. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Bug report
The
_PySemaphore_PlatformWait
function in parking_lot.c has three implementations:WaitForSingleObjectEx
(for Windows)sem_timedwait
(Linux and most other POSIX platforms)pthread_cond_timedwait
(macOS and possibly other platforms that don't havesem_timedwait
)We should follow the pattern used in
thread_pthread.h
where we prefer functions that support CLOCK_MONOTONIC. These aresem_clockwait
andpthread_cond_timedwait
after settingpthread_condattr_setclock
.Additionally, we should use
_PyTime_AsTimespec_clamp
instead of_PyTime_AsTimespec
(we don't want to raise errors in these code paths).Note that:
WaitForSingleObjectEx
isn't relative to any specific clock -- it just takes a timeout for N milliseconds in the futurepthread_condattr_setclock
, so we're stuck with the system clock on macOS. It's not clear to me if we use thepthread_cond_timedwait
for any other OS.Linked PRs
pthread_cond_timedwait_relative_np
in parking_lot.c when available #112616The text was updated successfully, but these errors were encountered: