Skip navigation.
Home
The QNX Community Portal

View topic - c programming for interrupts in qnx?

c programming for interrupts in qnx?

For discussion of realtime and/or embedded programming.

c programming for interrupts in qnx?

Postby hemanth » Wed Apr 02, 2014 6:22 am

client- server communication - client is sender and server is receiver. when the server receives the data on the ethernet interface(UDP) the kernel in the server is triggered. I am using QNX on the server side. server(i.e embedded pc target) is handling interrupts to trigger the embedded pc target (conatining QNX) to gain the attention to execute the newly arrived data.

I am calculating the time when the interrupt occurs and when it starts scheduling (calculating interrupt latency).

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[])
{
CreateSocket(); // socket receiving the data from client

ISR(); //function call for ISR

return 0;
}

my question : Is this the right way to create a ISR in qnx ?? how to check the above code is working fine ?? someone please help me ??
hemanth
Active Member
 
Posts: 20
Joined: Mon Dec 23, 2013 11:14 pm

Return to Realtime and Embedded

Who is online

Users browsing this forum: No registered users and 1 guest