Re: How can I get notified that a kernel thread has been terminated ?
Re: How can I get notified that a kernel thread has been terminated ?
- Subject: Re: How can I get notified that a kernel thread has been terminated ?
- From: Nicolas Connoud <email@hidden>
- Date: Fri, 05 Aug 2011 09:34:50 +0200
Hi Ken,
Many thanks for your reply,
> I don't believe there is a generic mechanism. Normally people in this
> situation use one of the standard synchronization mechanisms to wait
> for the thread to exit before finishing the unload of the kext
I have tried that. The kext-unload waits for a flag to be set (this is the last thing my thread function does) before carrying on with the unload. Still it is not enough.
I suppose my question really is :
- when the function of the worker thread (i.e. the one passed as first argument to kernel_thread_create) returns, does that really mean that the thread terminates at that point ? I imagine there must be some kind of low-level operations to be done to actually terminate the thread.
My point is: could it be that my worker thread function returns notifying my other thread by setting this flag, the scheduler then switches back to my kext-unload function but the actual thread gets really terminated at some later stage... after my kext has been unloaded ?
In the meantime, I am going to try again to debug it with gdb, see if I can find some more information.
Thanks again!
Nicolas
2011/8/4 Ken Hornstein
<email@hidden>
>My question is :
> - How can I get notified when the thread has terminated? Is it at all
>possible?
I don't believe there is a generic mechanism. Normally people in this
situation use one of the standard synchronization mechanisms to wait
for the thread to exit before finishing the unload of the kext (also -
have you tried debugging your kernel panic with gdb? That should at
least give you a better idea what is going on). So you'd have your
worker thread tell the kext-unload thread that it's finished as the last
thing it does.
> - I have read about thread_terminate() but it looks like this function in
>not available for kexts (KERNEL_PRIVATE only)
I see thread_terminate() is exported in the 6.0 version of
com.apple.kernel.libkern, at least on Snow Leopard. Not sure if you can
depend on it being around in Lion.
--Ken
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden