tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: nanosecond debiting cv_timedwait
On Fri, Mar 20, 2015 at 01:37:59PM +0000, Taylor R Campbell wrote:
> int cv_timedwaitns(kcondvar_t *, kmutex_t *, struct timespec *);
> int cv_timedwaitns_sig(kcondvar_t *, kmutex_t *, struct timespec *);
To me the small difference in the name doesn't adequately reflect the
semantic difference. A different name that makes the semantic difference
more obvious would be preferable.
We don't want people to think a mechanical conversion to:
struct timespec timeout = { .tv_sec = 1, .tv_nsec = 0 };
struct timespec now, end;
int error;
nanotime(&now);
timespecadd(&now, &timeout, &end);
while (!condition) {
error = cv_timedwait_sig(&sc->sc_cv, &sc->sc_lock,
&timeout);
if (error)
goto fail;
nanotime(&now);
if (timespeccmp(&end, &now, <) {
error = EWOULDBLOCK;
goto fail;
}
timespecsub(&end, &now, &timeout);
}
is going to work as before. Or does it?
But maybe that isn't mechanical enough.
--chris
Home |
Main Index |
Thread Index |
Old Index