// CSerialPDD:
ostInit();
CeSetPriority(m_dwPriority256);
CeSetThreadPriority(GetCurrentThread(), m_dwPriority256);
RETAILMSG(1,(TEXT("m_dwPriority256 current = %d\n"),CeGetThreadPriority(GetCurrentThread())));
ThreadStart(); // Start IST.
这是我的开发板串口驱动里的一段。
MDD.C里COM_Init
(void) pSerialHead->pHWObj->pFuncTbl->HWPostInit( pHWHead );
Cserpdd.cpp里的SerInit
会调到一个继承了CSerialPDD的类,这个类实现了CSerialPDD的虚函数PostInit(),上面这段代码就是新类里PostInit()的最后一段。
它的注释是启动 IST,可是我这么知道哪个是IST呢?
是在MDD.C里,还是在Cserpdd.cpp里,或是在继承了CSerialPDD的新类里。它们是如何建立关系的呢?
我的一般理解是在建立线程时,就把相应的函数指针做参数,这样就可以启动这个函数了。
在PB的help里:
HANDLE GetCurrentThread(void);
This function returns a pseudohandle for the current thread。
A pseudohandle is a special constant that is interpreted as the current thread handle.
The calling thread can use this handle to specify itself when a thread handle is required. 这句有什么特殊的含义吗?
This handle has the maximum possible access to the thread object.
The function cannot be used by one thread to create a handle that can be used by other threads to refer to the first thread. The handle is always interpreted as referring to the thread that is using it.
The pseudohandle does not need to be closed when it is no longer needed.