cvs commit: src/sys/dev/fdc fdc.c fdcvar.h

John Baldwin jhb at
Thu Sep 23 18:35:31 PDT 2004

On Thursday 23 September 2004 09:19 pm, M. Warner Losh wrote:
> In message: <200409231923.40285.jhb at>
>             John Baldwin <jhb at> writes:
> : Note that relying on a wakeup from your own code is not safe if you
> : expect fdc to be a module since you could wakeup the thread doing the
> : kldunload (and thus detach) and then be interrupted for an interrupt and
> : it could unmap the memory backing that function before you get a chance
> : to run again resulting in a panic.  There is a special wakeup on the
> : proc pointer in exit1() for kthreads to handle this case.
> Wouldn't simply unregistering your interrupt before killing the worker
> thread handle this case?  You are sleeping in the detach path then
> until the worker thread goes away.  Once it is gone, it is safe to
> proceed to detach.  cbb does this and I've not had any problems
> unloading it.  In fact, it was how you told me to write cbb a long
> time ago.  Once the bus_teardown_intr() returns, you are guaranteed
> the interrupt won't get called.

What about someone else's interrupt preempting you?

> : I should
> : likely move that into kthread_exit() however (which wouldn't be a
> : functional change as far as you are concerned).
> I'm not sure I understand this part of your statement.

I currently have a wakeup() buried in exit1() conditional on p_flag & 
P_KTHREAD.  I should just move it to kthread_exit() so it happens sooner and 
is less obfuscated.

John Baldwin <jhb at>  <><
"Power Users Use the Power to Serve"  =

More information about the cvs-src mailing list