Skip to content

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

Closed
@cfriedt

Description

@cfriedt

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

Metadata

Metadata

Assignees

Labels

area: POSIXPOSIX API LibrarybugThe issue is a bug, or the PR is fixing a bugpriority: mediumMedium impact/importance bug

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions