Re: How to kill an IOKit thread?
Re: How to kill an IOKit thread?
- Subject: Re: How to kill an IOKit thread?
- From: Brian Bergstrand <email@hidden>
- Date: Wed, 31 Jul 2002 14:44:00 -0500
At 8:53 PM +0200 7/31/02, Heiko Panther wrote:
I'm using an IOKit thread in my kext. The thread usually blocks in a
system call.
From my main workloop, I want to terminate the thread on certain
conditions. There is an explanation on how to do so in IMX:Kernel
Programming.
thread_terminate(getact_thread(thread_t thread));
I think "thread_terminate (current_act());" is the recommended
method. It's what I use.
Only problem: I can't seem to find the function getact_thread(). Any
clues? How do I get rid of the thread?
Do not, repeat DO NOT kill a thread from another thread. It is only
safe to kill a thread from within itself. The most common way to get
around this limitation is to check a flag in the thread that needs to
exit and if the flag is true then exit the thread. So in your case,
in your main thread you would set the flag, then signal your other
thread using a semaphore. If you need to wait for the thread to exit,
block on a semaphore in the main thread that the exiting thread
signals just before terminating.
HTH.
--
Brian Bergstrand
<
http://www.classicalguitar.net/brian/> PGP Key ID: 0xB6C7B6A2
We're the Soprano's in a pickup truck. - Daryll Hammond as Bill Clinton on SNL
_______________________________________________
darwin-kernel mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/darwin-kernel
Do not post admin requests to the list. They will be ignored.