This class is only available in the RT environment. It has been derived from CIThread to ease the creation of an interrupt thread that processes interrupts together with an interrupt handler. It must be used to derive an application specific interrupt thread class, or it can be used directly to control a thread object.
The interrupt thread and handler cooperate based on some assumptions:
for every interrupt, the handler signals the thread
while an interrupt is being processed, the interrupt level is disabled (max signals = 1)
the thread has no timeout on the wait call
the process has a maximum priority that allows the creation of the interrupt thread
The class contains a static call that acts as an interrupt handler. When deriving from the CIIntThread class and overruling the handler, care should be taken in obeying all rules on the contents of such a handler.
Constructor
Destructor
Create
InitInstance
DoForever
OnSignal
Enable
The following member variable is only available to the members of the class and its derived classes:
WORD m_wLevel;
See CIThread::Constructor.
See CIThread::Destructor.
If the object is already attached, it is first detached. Then this call creates a new RT thread object and attaches it to the object.
DWORD CIIntThread::Create( char * pszName, WORD wLevel, BYTE byMaxInt=1, DWORD dwMilliseconds=WAIT_FOREVER, DWORD dwStack=4096, BOOLEAN bShared=FALSE );
pszName
wLevel
byMaxInt
0 |
No interrupt thread will be associated with this handler. In other words the handler will never call SignalRtInterruptThread. |
1-254 |
The number of outstanding SignalRtInterruptThread requests that can exist. When this limit is reached the interrupt is disabled. |
dwMilliseconds
NO_WAIT |
The thread does not wait. |
WAIT_FOREVER |
The thread waits for its request to be fully satisfied. |
1-655349 |
Calling thread goes to sleep for this many milliseconds, after which it awakes. |
Note: The kernel converts milliseconds to high-level ticks.
dwStack
bShared
TRUE |
The level can be shared with other classes. |
FALSE |
The level cannot be shared with other classes. |
E_OK
E_MEM
E_LIMIT
E_SLOT
E_PARAM
wLevel
has a bad value, dwStack
contains a value of less than 2048, or the name is too long or is improperly formatted.
E_CONTEXT
See CIThread::DoForever. CIIntThread::InitInstance is called by the framework at the start of the thread; it should never be called explicitly. CIIntThread::InitInstance installs the interrupt handler and turns itself into an interrupt thread. When overruling, it is recommended to include a call to the default call, as in this example:
BOOLEAN CIMyIntThread::InitInstance() { // actions that must precede the default init if (!CIIntThread::InitInstance()) return FALSE; // actions that must follow the default init return TRUE; // or FALSE if initialization failed }
See CIThread::DoForever. CIIntThread::DoForever is called by the framework in the body of the thread; it should never be called explicitly. CIIntThread::DoForever waits for a signal from the interrupt handler (no timeout), calls the OnSignal member (only after successful signal) and returns a boolean status (TRUE for success, FALSE for failure). When overruling this call, do not include a call to the default call.
CIIntThread::OnSignal is called by the framework when a signal has been received successfully; it should never be called explicitly. CIIntThread::OnSignal just returns TRUE. When overruling this call, there is no need to call the default call.
BOOLEAN CIIntThread::OnSignal( BOOLEAN bSignal );
bSignal
TRUE Indicates a real interrupt; the result must be TRUE to let the thread continue.
FALSE Indicates a timeout; terminates the thread.
This call enables or disables the hardware interrupt signal.
DWORD CIIntThread::Enable( BOOLEAN bState );
bState
TRUE |
(Default) Enabled. |
FALSE |
Disabled. |
E_OK
E_CONTEXT
E_EXIST