Skip to content
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

[osx] use CLOCK_REALTIME for init_timeout #1579

Merged
merged 1 commit into from
Sep 15, 2024

Conversation

connorjclark
Copy link
Contributor

@connorjclark connorjclark commented Sep 9, 2024

#1511 changed osx clocks to use CLOCK_MONOTONIC_RAW, but that is an issue for the timeout structure because pthread expects an absolute system time. This resulted in timed event calls returning instantly.

See https://pubs.opengroup.org/onlinepubs/009695399/functions/pthread_cond_timedwait.html#:~:text=Timed%20Wait%20Semantics

liballeg#1511 changed osx clocks to use CLOCK_MONOTONIC_RAW, but that is an issue for the timeout structure because pthread expects an absolute system time. This resulted in timed event calls returning instantly.
@SiegeLord
Copy link
Member

I couldn't reproduce the instant timeouts (I used ex_timedwait, suspended the system, resumed and then saw if the timeouts were affected... they were not), but your reasoning seems reasonable.

@connorjclark
Copy link
Contributor Author

connorjclark commented Sep 15, 2024

Perhaps by attaching a debugger you could get the monotonic raw clock to drift from system clock... I think I was using a debugger. It could also be implementation-defined whether the clocks even align on process start (just guessing).

@SiegeLord
Copy link
Member

I tried the debugger, but still no luck. I don't mind merging this if it helps on your system though.

@SiegeLord SiegeLord merged commit 57120a9 into liballeg:master Sep 15, 2024
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants