On Jun 19, 2008, at 11:33 PM, James Chan wrote:
I trace some source code download form ADC, but some function call I
can not understand.
There are 2 functions named "thread_call_allocate" and
"thread_call_enter", but I can not find any document on XCode
reference library.
These functions are of the "if you don't understand what they're
doing, you probably shouldn't be using them" variety.
On the document "Kernel Porgramming Guide" - Kernel Thread APIs, it
shows there is a IOCreadeThread API to create thread in kernel.
Does any know what kind of difference between using IOCreadeThread
and thread_call_allocate + thread_call_enter??
Yes.
Where I can get the document??
You already have it; it's the source code. The thread_call_* API
manipulates thread call structures, which are typically used to
schedule deferred tasks in non-I/O Kit contexts. For I/O Kit threads
you will typically want to use a workloop and the relevant event sources.
If I using thread_call_allocate and thread_call_enter, the task ID of
this thread is the some with which task??
thread_call_allocate/thread_call_enter do not create threads.
IOCreateThread will create a thread associated with the kernel task.
Typically, when someone asks "how do I create a thread in the [Darwin]
kernel", they are trying to port a Windows driver, or write a driver
or kernel extension in the Windows style. The best advice that can be
offered when you are doing this is - stop.
Darwin is not Windows, and I/O Kit is not WDM. You will be much
happier learning how I/O Kit drivers and kernel extensions are meant
to be written, and writing a driver or extension in that style.
Trying to do things the Windows Way will only make you sad.
= Mike