tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: How to wait on cv_timedwait() correctly
> On Jan 30, 2025, at 6:37 AM, Stephan <stephanwib%googlemail.com@localhost> 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
Home |
Main Index |
Thread Index |
Old Index