Сценарий: клиент отправляет данные, а сервер получает данные от клиента через уровень Ethernet (udp). Когда сервер получает данные от клиента на уровне IP (ядре). Он прерывает работу ядра и ядра для выполнения данных клиентом, поэтому я хочу создать функцию обслуживания прерываний, чтобы перехватывать прерывания от карты сетевой службы.
Я использую Interruptattach API для обработки прерывания от сетевой карты и структуры sigevent для вызова конкретной функции. http://www.qnx.com/developers/docs/6.3.0SP3/neutrino/lib_ref/i/interruptattach.html#HandlerFunction
это правильный способ обработки прерываний в qnx ??
volatile int id1, id2, id3;
const struct sigevent *handler1(void *area, int id1)
{
volatile double KernelStartExecutionTime;
KernelStartExecutionTime = GetTimeStamp(); // calculating the time when the kernel starts executing
TASK1(Task2ms_Raster);
return (NULL);
}
const struct sigevent *handler2(void *area, int id2)
{
volatile double KernelStartExecutionTime;
KernelStartExecutionTime = GetTimeStamp(); // calculating the time when the kernel starts executing
TASK2(Task10ms_Raster);
return (NULL);
}
const struct sigevent *handler3(void *area, int id3)
{
volatile double KernelStartExecutionTime;
KernelStartExecutionTime = GetTimeStamp(); // calculating the time when the kernel starts executing
TASK3(Task100ms_Raster);
return (NULL);
}
/*kernel calls attach the interrupt function handler to the hardware interrupt specified by intr(i.e irq) */
// InterruptAttach() : Attach an interrupt handler to an interrupt source
// interrupt source is handler1 for this example
void ISR(void)
{
volatile int irq = 0; //0 : A clock that runs at the resolution set by ClockPeriod()
ThreadCtl (_NTO_TCTL_IO, NULL);
id1 = InterruptAttach(irq, &handler1, NULL, 0, 0);
id2 = InterruptAttach(irq, &handler2, NULL, 0, 0);
id3 = InterruptAttach(irq, &handler3, NULL, 0, 0);
}
int main(int argc, char *argv[])
{
Xcp_Initialize();
CreateSocket();
ISR(); //function call for ISR
return 0;
}
другой вопрос: если я хочу вызвать другую функцию в структуре sigevent, должен ли я использовать для этого другой ISR (т.е. как обрабатывать несколько функций из прерывания)?
Я изменил свой код, как указано выше. Будет ли это эффективно, если я сделаю, как указано выше. Одна функция ISR с InterruptAttach API для трех разных обработчиков.