客户端 - 服务器通信 - 客户端是发送者,服务器是接收者。当服务器在以太网接口(UDP)上接收到数据时,服务器中的内核被触发。我在服务器端使用 QNX。服务器(即嵌入式 pc 目标)正在处理中断以触发嵌入式 pc 目标(包含 QNX)以获取注意力以执行新到达的数据。
const struct sigevent *handler1(void *area, int id1)
{
volatile double KernelStartExecutionTime;
struct sigevent *event = (struct sigevent *)area;
KernelStartExecutionTime = GetTimeStamp(); // calculating the time when the kernel //starts executing
measurements[18] = KernelStartExecutionTime ;
//return (NULL);
return event;
}
/*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) //void *ISR (void *arg)
{
/* the software must tell the OS that it wishes to associate the ISR with a particular source of interrupts.
* On x86 platforms, there are generally 16 hardware Interrupt Request lines (IRQs) */
volatile int irq = 0; //0 : A clock that runs at the resolution set by ClockPeriod()
struct sigevent event;
event.sigev_notify = SIGEV_INTR;
ThreadCtl (_NTO_TCTL_IO, NULL); // enables the hardware interrupt
id1 = InterruptAttach(irq, &handler1, &event, sizeof(event), 0); // handler1 is the ISR
while(1)
{
InterruptWait( 0, NULL );
InterruptUnmask(irq, id1);
}
InterruptDetach( id1);
}
int main(int argc, char *argv[]) {
ISR(); //function call for ISR
// pthread_create (NULL, NULL, ISR, NULL);
return 0;
}
问题:我应该创建一个新线程来处理主线程中的中断吗?