title: interrupt service routine in qnx?
body: <p>Scenario : Client is sending a data and the server is receving the data from client via ethernet layer (udp). When the server receives a data from the client on the ip layer (kernel). It interrupts the kernel and kernel as to execute the data by the client, so I want to create a interrupt service function to catch the interrupt from the network service card.</p>
  
  <p>I am using Interruptattach api to handle the interrupt from the network interface card and sigevent structure to call the specific function.
  <a href="http://www.qnx.com/developers/docs/6.3.0SP3/neutrino/lib_ref/i/interruptattach.html#HandlerFunction" rel="nofollow">http://www.qnx.com/developers/docs/6.3.0SP3/neutrino/lib_ref/i/interruptattach.html#HandlerFunction</a></p>
  
  <p>is it the right way to handle interrupts in qnx ??</p>
  
  <pre><code>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, &amp;handler1, NULL, 0, 0);
   id2 = InterruptAttach(irq, &amp;handler2, NULL, 0, 0);
   id3 = InterruptAttach(irq, &amp;handler3, NULL, 0, 0);
  
  
   }
  
  int main(int argc, char *argv[])
  {
       Xcp_Initialize();
  
       CreateSocket();
  
       ISR();      //function call for ISR
  
       return 0;
  }
  </code></pre>
  
  <p>another question : if I want to call another function in the sigevent structure then should I use another ISR for that (i.e. how to handle multiple function from the interrupt)?</p>
  
  <p>I modified my code as above. Will it be efficient if I do like above. One ISR function with InterruptAttach API for three different handler.</p>