sleep/wakeup sequence using tsleep_interlock

Aggelos Economopoulos aoiko at cc.ece.ntua.gr
Sat Aug 18 14:54:43 PDT 2007


According to the comment preceding tsleep_interlock() in kern_synch.c:

/*
 * This is a dandy function that allows us to interlock tsleep/wakeup
 * operations with unspecified upper level locks, such as lockmgr locks,
 * simply by holding a critical section.  The sequence is:
 *
 *	(enter critical section)
 *	(acquire upper level lock)
 *	tsleep_interlock(blah)
 *	(release upper level lock)
 *	tsleep(blah, ...)
 *	(exit critical section)

It is not obvious to me why the first two operations can't be reversed (i.e. 
first acquire lock, then enter critical section). Can they?

TIA,
Aggelos





More information about the Kernel mailing list