plan9fox/sys
cinap_lenrek ac52599eef ether82563: avoid deadlock due to icansleep() trying to acquire Rbpool.Lock
icansleep() violates the lock ordering due to the following cases:

rbfree(): ilock(Rbpool.Lock) -> wakeup(): spli(), lock(Rbpool.Rendez)
sleep(): splhi(), lock(Rbpool.Rendez) -> icansleep(): ilock(Rbpool.Lock)

erik fixed this moving the wakeup() out of the ilock() in rbfree(),
but i think it is an error to try acquiering a ilock in sleeps wait
condition function in general.

so this is what we do:

in the icansleep() function, we check for the *real* event we care about;
that is, if theres a buffer available in the Rbpool. this is to handle
the case when rbfree() makes a buffer available *before* it sees us
setting p->starve = 1.

p->starve is now just used to gate rbfree() from calling wakeup() as
an optimization.

this might cause spurious wakeups but they are not a problem. missed
wakeups is the thing we have to prevent.
2013-07-26 01:51:03 +02:00
..
doc /sys/doc: permissions for cleanps, mkdirlist, mkfilelist 2012-10-20 19:09:54 +02:00
games/lib fortunes: Let me put in a word about the Apple wireless trackpad. 2013-07-05 15:41:51 -04:00
include draw: add badrect() function to reject zero, negative size or orverly huge rectangles 2013-06-16 19:01:46 +02:00
lib acid: fix dumptree() acid function to work in kernel debug, update malloc.acid and pool.acid files 2013-06-10 01:13:21 +02:00
man tojpg, totif: change flags to better match those of the decoders 2013-07-20 12:11:52 -04:00
src ether82563: avoid deadlock due to icansleep() trying to acquire Rbpool.Lock 2013-07-26 01:51:03 +02:00