You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to use PiFutex::lock_pi_until() and am hitting an issue with FUTEX_LOCK_PI and std::time::Instant using different clocks. It's manifesting as PiFutex::lock_pi_until() returning nearly immediately, regardless of the timeout value.
For example,
let futex = linux_futex::PiFutex::<linux_futex::Private>::new(1);// Non-zero -> locked by someone elseprintln!("{:?}", std::time::Instant::now());let result = futex.lock_pi_until(std::time::Instant::now() + std::time::Duration::from_secs(2));println!("{:?}", std::time::Instant::now());dbg!(result);
FUTEX_LOCK_PI is documented as using CLOCK_REALTIME, while std::time::Instant (used by lock_pi_until()) is implemented with CLOCK_MONOTONIC.
How is PiFutex::lock_pi_until() intended to be used? Is there a recommendation for converting between std::time::SystemTime (which uses CLOCK_REALTIME) and std::time::Instant?
Have you considered adding support for FUTEX_LOCK_PI2, which allows selecting a clock and could be used with CLOCK_MONOTONIC?
Thanks!
The text was updated successfully, but these errors were encountered:
It seems like modifying linux-futex to use FUTEX_LOCK_PI2 instead "just works", but there's a much higher Linux kernel requirement associated with that. I'll at least add it to rust-lang/libc (PR), since it seems to be absent.
Thanks! It's fixed in 8f75c58. lock_pi_until now accepts either an SystemTime or an Instant, and picks either FUTEX_LOCK_PI or FUTEX_LOCK_PI2 depending on that.
I'm trying to use
PiFutex::lock_pi_until()
and am hitting an issue withFUTEX_LOCK_PI
andstd::time::Instant
using different clocks. It's manifesting asPiFutex::lock_pi_until()
returning nearly immediately, regardless of the timeout value.For example,
outputs
FUTEX_LOCK_PI
is documented as usingCLOCK_REALTIME
, whilestd::time::Instant
(used bylock_pi_until()
) is implemented withCLOCK_MONOTONIC
.PiFutex::lock_pi_until()
intended to be used? Is there a recommendation for converting betweenstd::time::SystemTime
(which usesCLOCK_REALTIME
) andstd::time::Instant
?FUTEX_LOCK_PI2
, which allows selecting a clock and could be used withCLOCK_MONOTONIC
?Thanks!
The text was updated successfully, but these errors were encountered: