> On Jan 30, 2025, at 6:37 AM, Stephan <stephan...@googlemail.com> wrote:
> 
> I have seen that cv_signal() on a CV unblocks all threads waiting on
> it, instead of just one. That this could happen is briefly mentioned
> in condvar(9).

cv_signal() unblocks only a single thread.  The implementation is in 
kern/kern_condvar.c, and it’s very clear and obvious how it works.  I assume 
what you’re referring to is the warning about spurious wakes, which is in the 
description if cv_wait(), and is a completely separate issue.

> I think the problem is that when cv_timedwait_sig() is called
> repeatedly, the original timeout is used again and again, adding up to
> an unpredictable amount of time.
> 
> If that is the case, how can it be solved best? Is
> cv_timedwaitbt_sig() suitable? Or should one track sleep and wakeup
> times and calculate a new timeout each time?

I think cv_timedwaitbt_sig() should do the job here.

-- thorpej

Reply via email to