strange KASSERT in _sleep()
John-Mark Gurney
gurney_j at resnet.uoregon.edu
Sat Aug 11 13:23:33 PDT 2007
Roman Divacky wrote this message on Sat, Aug 11, 2007 at 14:46 +0200:
> tsleep() maps to _sleep() with lock = NULL,
>
> the _sleep() contains this:
>
> KASSERT(timo != 0 || mtx_owned(&Giant) || lock != NULL ||
> ident == &lbolt, ("sleeping without a lock"));
>
>
> which simplifies for tsleep(foo, ...) where foo != lbolt to
> "timo != 0 || mtx_owned(&Giant)"
>
> why do I have to hold Giant or have timo != 0 when calling tsleep?
To prevent a deadlock.. It would be possible for you to miss your
wakeup if you don't have a lock (such as Giant) held... By forcing
a timeout, you guarantee that it will check the condition sometime
in the future...
--
John-Mark Gurney Voice: +1 415 225 5579
"All that I will do, has been done, All that I have, has not."
More information about the freebsd-hackers
mailing list