Re: strange KASSERT in _sleep()
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."
_______________________________________________
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"
討論串 (同標題文章)