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: Ken Hornstein <email@hidden>
- Date: Fri, 05 Aug 2011 09:20:32 -0400
>> 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.
Hrm. The stuff I'm doing has a number of worker threads and they all do
that, and it works fine. It feels to me like something else is going
wrong here. And considering that this is pretty common ... I have to
think that there's some other problem you're running into at kext unload
time.
>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 ?
I can see what you mean about the scheduler switching back to the kext worker
thread, but like I said if this was a problem then a LOT of people would
be running into it. I don't know what other cleanup is required after
a worker thread function exits, but I don't think it's a lot. Anyway,
debugging it with gdb should tell you for sure.
(Also, it occurs to me that even after a kext is unloaded a worker thread
running out of that kext MIGHT ... and that's a big MIGHT ... still run
okay for a little while until that bit of memory has been reused. But
that's just a guess and could easily be wrong).
--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