Книга: Microsoft Windows Embedded CE 6.0 Exam Preparation Kit

Interrupt Service Threads

Interrupt Service Threads

An IST is a regular thread that performs additional processing in response to an interrupt, after the ISR has completed. The IST function typically includes a loop and a WaitForSingleObject call to block the thread infinitely until the kernel signals the specified IST event, as illustrated in the following code snippet. However, before you can use the IST event, you must call InterruptInitialize with the SYSINTR value and an event handle as parameters so that the CE kernel can signal this event whenever an ISR returns the SYSINTR value. Chapter 3 provides detailed information about multithreaded programming and thread synchronization based on events and other kernel objects.

CeSetThreadPriority(GetCurrentThread(), 200);
// Loop until told to stop
while(!pIst->stop) {
 // Wait for the IST event.
 WaitForSingleObject(pIst->hevIrq, INFINITE)
 // Handle the interrupt.
 InterruptDone(pIst->sysIntr);
}

When the IST has completed processing an IRQ, it should call InterruptDone to inform the system that the interrupt was processed, that the IST is ready to handle the next IRQ, and that the interrupt can be reenabled by means of an OEMInterruptDone call. Table 6-6 lists the OAL functions that the system uses to interact with the interrupt controller to manage interrupts.

Table 6-6 OAL functions for interrupt management

Function Description
OEMInterruptEnable This function is called by the kernel in response to InterruptInitialize and enables the specified interrupt in the interrupt controller.
OEMInterruptDone This function is called by the kernel in response to InterruptDone and should unmask the interrupt and acknowledge the interrupt in the interrupt controller.
OEMInterruptDisable This function disables the interrupt in the interrupt controller and is called in response to the InterruptDisable function.
OEMInterruptHandler For ARM processors only, this function identifies the interrupt SYSINTR that occurs by looking at the status of the interrupt controller.
HookInterrupt For processors other than ARM, this function registers a callback function for a specified interrupt ID. This function must be called in the OEMInit function to register mandatory interrupts.
OEMInterruptHandlerFIQ For ARM processors, used to handle interrupts for the Fast Interrupt (FIQ) line.

CAUTION

WaitForMultipleObjects restriction

Do not use the WaitForMultipleObjects function to wait for an interrupt event. If you must wait for multiple interrupt events, you should create an IST for each interrupt.

Оглавление книги

Оглавление статьи/книги

Генерация: 1.254. Запросов К БД/Cache: 3 / 0
поделиться
Вверх Вниз