Page MenuHomeFreeBSD

libthr: implement pthread_cond_clockwait(3)
ClosedPublic

Authored by kib on Jul 26 2026, 12:15 AM.
Tags
None
Referenced Files
F171911766: D58463.id182715.diff
Mon, Sep 14, 12:58 PM
F171882311: D58463.id182738.diff
Mon, Sep 14, 7:53 AM
Unknown Object (File)
Sat, Sep 12, 12:41 PM
Unknown Object (File)
Fri, Sep 11, 2:51 PM
Unknown Object (File)
Wed, Sep 9, 7:35 PM
Unknown Object (File)
Tue, Sep 8, 1:04 PM
Unknown Object (File)
Mon, Sep 7, 10:22 PM
Unknown Object (File)
Sun, Sep 6, 1:36 PM
Subscribers

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kib requested review of this revision.Jul 26 2026, 12:15 AM

Apply the same check for clockid on the UMTX_CV_WAIT_UC as for UMTX_CV_WAIT.

Avoid adding new umtx_op(2) request, add a flag for cvwait op.

The test changes seem very reasonable. Just one style(9) suggestion to make the information easier for humans to find test names.

contrib/netbsd-tests/lib/libpthread/t_condwait.c
178–179 ↗(On Diff #182720)

(just picking a single instance)
This helps preserve the test name as a single string and makes it easier to find for humans.

This revision is now accepted and ready to land.Jul 26 2026, 4:27 PM
contrib/netbsd-tests/lib/libpthread/t_condwait.c
178–179 ↗(On Diff #182720)

(just picking a single instance)
This helps preserve the test name as a single string and makes it easier to find for humans.

I should have said "test description", not "test name" here.

kib marked 2 inline comments as done.

Make tests descriptions single line.

This revision now requires review to proceed.Jul 26 2026, 8:38 PM
contrib/netbsd-tests/lib/libpthread/t_condwait.c
97 ↗(On Diff #182738)
lib/libsys/_umtx_op.2
803 ↗(On Diff #182738)
lib/libthr/thread/thr_cond.c
220 ↗(On Diff #182738)

Why not initialize utime right before the _thr_ucond_wait() call below?

share/man/man3/pthread_cond_timedwait.3
54 ↗(On Diff #182738)

... and .Fn pthread_cond_clockwait functions atomically block...

80 ↗(On Diff #182738)

Is this the only difference between pthread_cond_timedwait() and pthread_cond_clockwait()? The man page should say so explicitly.

sys/kern/kern_umtx.c
4197

Why permit CVWAIT_UMTX_TIME without a _umtx_time?

kib marked 6 inline comments as done.

Handle the review notes.
The biggest change is that CVWAIT_UMTX_TIME without umtx_time causes EINVAL.
Man page updates.
Minor code editing.

markj added inline comments.
lib/libthr/thread/thr_umtx.c
272 ↗(On Diff #182784)

I do not see much utility in having this common function. There is not much code shared between the two usages, so I would instead split this into _thr_ucond_timedwait() and _thr_ucond_clockwait() or so.

This revision is now accepted and ready to land.Jul 27 2026, 2:52 PM
kib marked an inline comment as done.Jul 27 2026, 3:54 PM
kib added inline comments.
lib/libthr/thread/thr_umtx.c
272 ↗(On Diff #182784)

This was how I did used CVWAIT_UMTX_TIME initially. But I disliked the need for ETIMEDOUT logic that was repeated in both functions. IMO this is relatively non-trivial to benefit from avoiding the duplication.