Skip to content

posix: pthread: condition variables always wait on clock monotonic #88587

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

Open
cfriedt opened this issue Apr 14, 2025 · 0 comments
Open

posix: pthread: condition variables always wait on clock monotonic #88587

cfriedt opened this issue Apr 14, 2025 · 0 comments
Assignees
Labels
area: POSIX POSIX API Library bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug

Comments

@cfriedt
Copy link
Member

cfriedt commented Apr 14, 2025

Describe the bug

Two issues in one:

  1. The POSIX spec indicates that the default clock used for condition variables should be CLOCK_REALTIME. However, Zephyr effectively always uses CLOCK_MONOTONIC.

  2. Additionally, when a pthread_condattr_t is initialized as using any clock id, the clock id in that attribute is ignored in subsequent calls to pthread_cond_timedwait().

Please also mention any information which could help others to understand
the problem you're facing:

  • What target platform are you using? any
  • What have you tried to diagnose or workaround this issue? just inspeced the source
  • Is this a regression? No

To Reproduce
Steps to reproduce the behavior:

Can fill in later, if necessary. It's pretty evident from the source though.

Expected behavior
Should be able to specify which clock to use for pthread_cond_timedwait(), as long as POSIX_CLOCK_SELECTION is enabled.

Impact
This will throw conformant applications a bit of a curveball in terms of timing expectations.

Logs and console output

Environment (please complete the following information):

  • OS: any
  • Toolchain (e.g Zephyr SDK, ...): Zephyr SDK v0.17.0
  • Commit SHA or Version used: d453fb9

Additional context
Discovered in the context of #88547

@cfriedt cfriedt added area: POSIX POSIX API Library bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug labels Apr 14, 2025
@cfriedt cfriedt self-assigned this Apr 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: POSIX POSIX API Library bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug
Projects
None yet
Development

No branches or pull requests

1 participant