tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: kernel condvars: how to use?



> Date: Thu, 7 Dec 2017 18:24:22 -0500 (EST)
> From: Mouse <mouse%Rodents-Montreal.ORG@localhost>
> 
> On reflection, I think I know why.  Userland's syscall handler took the
> mutex in preparation for cv_wait_sig(), the interrupt happens, my code
> is called (verified with a printf), and it tries to take the same mutex
> so it can cv_broadcast().  Of course, the mutex is held and, because
> it's held by code which can't run until the interrupt handler exits,
> will never be released.  Then, when a hardware interrupt hit it found
> the biglock held....

Note that if you use a mutex in a thread _and_ an interrupt handler,
you must initialize the mutex with the ipl at which the interrupt
handler runs.  That way, while you hold the lock, it will block the
interrupt handler too, which avoids the scenario you described.

It's possible that's what happened in the stack trace you showed if
you passed the a too-low IPL_* to mutex_init, but still hard to tell
without reference to the code.


Home | Main Index | Thread Index | Old Index