INtime SDK Help
CIIntThread
This topic contains these sections:

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.

Class members

Constructor

Destructor

Create

InitInstance

DoForever

OnSignal

Enable

Member variables

The following member variable is only available to the members of the class and its derived classes:

WORD m_wLevel;

CIIntThread::Constructor

See CIThread::Constructor.

CIIntThread::Destructor

See CIThread::Destructor.

CIIntThread::Create

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.

Syntax

DWORD CIIntThread::Create(
    char * pszName, 
    WORD wLevel,
    BYTE byMaxInt=1,
    DWORD dwMilliseconds=WAIT_FOREVER,
    DWORD dwStack=4096,
    BOOLEAN bShared=FALSE
);

Parameters

pszName
Specifies a name that, if not empty, is used to catalog the RT object.
wLevel
Indicates the level for the interrupt to be serviced (specified as one of the values IRQ0_LEVEL up to IRQ15_LEVEL).
byMaxInt
Specifies the number of interrupt flags:
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
The number of milliseconds the calling thread waits:
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
Indicates the number of bytes to be reserved for stack space; it should be a multiple of 4 and at least 2048; if omitted, 4096 is used. The result is a status indicating success or failure.
bShared
Specifies whether to share the level with other handlers (this is handled by coding inside the classes). If you omit this parameter, the effect is the same as including this parameter with a value of FALSE. You can enter one of these values:
TRUE The level can be shared with other classes.
FALSE The level cannot be shared with other classes.

Status

E_OK
No exceptional conditions occurred.
E_MEM
The current process cannot create a thread as specified with the memory available.
E_LIMIT
Either the calling thread's process already reached its object or thread limit, or the job does not allow the required priority, or the object directory is full.
E_SLOT
You cannot create more RT objects because the GDT's slots are full.
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
The object directory already contains the name being cataloged, or the interrupt level already has a handler.

CIIntThread::InitInstance

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 }

CIIntThread::DoForever

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

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.

Syntax

BOOLEAN CIIntThread::OnSignal(
    BOOLEAN bSignal
);

Parameters

bSignal
Indicates the signal.

Return Value

TRUE Indicates a real interrupt; the result must be TRUE to let the thread continue.

FALSE Indicates a timeout; terminates the thread.

CIIntThread::Enable

This call enables or disables the hardware interrupt signal.

Syntax

DWORD CIIntThread::Enable(
    BOOLEAN bState
);

Parameters

bState
Indicates the required state for the level:
TRUE (Default) Enabled.
FALSE Disabled.
The result is a status indicating success or failure:.

Status

E_OK
No exceptional conditions occurred.
E_CONTEXT
An interrupt overflow on the specified level exists.
E_EXIST
The object is not attached.
See Also

Interrupts