Re: strange KASSERT in _sleep()

看板FB_hackers作者時間18年前 (2007/08/13 14:39), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/2 (看更多)
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"
文章代碼(AID): #16l_oG00 (FB_hackers)
文章代碼(AID): #16l_oG00 (FB_hackers)