int id1; //variables used in the isr should be volatile
struct sigevent event;
int chid;
/* this function is your code */
const struct sigevent *ISR(void *area, int id1)
{
StartInterruptTime = ClockCycles();
return (&event);
}
/* this function is your code */
void *ConfigureISR(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) */
StartInterruptTime = GetTimeStamp(); //startTime of the interrupt
// volatile int irq = 11; //0 : A clock that runs at the resolution set by ClockPeriod()
ThreadCtl (_NTO_TCTL_IO, NULL); // enables the hardware interrupt
// Initialize event structure
//
// Setup COID and event
//
/* Tell the kernel to attach an interrupt signal event to this thread */
chid = ChannelCreate( 0 );
SIGEV_INTR_INIT( &event);
// ISR is the interrupt service routine
id1 = InterruptAttachEvent(irq, ISR, NULL);
if (id1 == -1)
{
fprintf(stderr, “can’t attach to IRQ\n”);
perror (NULL);
exit (EXIT_FAILURE);
}
InterruptWait(0, NULL);
InterruptLatency = (double) (EndInterruptTime - StartInterruptTime)/(double)(SYSPAGE_ENTRY(qtime)->cycles_per_sec);
//I am storing the difference between the time in array.
measurements[17] = InterruptLatency;
return (EXIT_SUCCESS);
}
int main(int argc, char *argv[])
{
pthread_t thread_id;
// I am creating the socket to receive data from client
if ((sock = CreateSocket()) < 0) {
perror ("Create_socket");
exit (1);
}
// this is my timer which is calling the task in the background for every2 milliseconds, 10ms and 100ms
if (pthread_create(&thread_id, NULL, &rastertask, NULL)) {
perror ("pthread_create");
exit (1);
}
do
{
socklen_t len;
len = sizeof(client);
printf("NEW DATA ARRIVED\n");
//non blocking mode : MSG_DONTWAIT
// API to receive data from the client.
rc=recvfrom(sock, buf, 256, 0, (struct sockaddr*) &client, &len);
if(rc==0)
{
printf("Server has no connection..\n");
break;
}
if(rc==-1)
{
if (errno == SIGINT)
continue;
printf("Oh dear, something went wrong with read()! %s\n", strerror(errno));
break;
}
// I AM CALLING THE API FOR INTERRUPT HERE
ConfigureISR ();
}
} while (1);
close(sock);
return 0;
}
There is a client and server : Client is sending data to the server . Server is receiving the data and sending a response back to the client. Ethernet interface for communication between client and server. Client is a tool (intecrio tool) for sending data. Server is an embedded PC target (fit pc2) with qnx rtos. Server wi be executing some other process. When server receives the data along the Ethernet interface then the kernel as to stop what it is doing. And start executing the newly arrived data.
My task - I want to take the timestamp when the kernel is interrupted and time at which the kernel starts handling it. In QNX microkernel- I am not able to take the timestamp at which the kernel is interrupted . So I am planning to take the timestamp at which the interrupt handler is called by the kernel . Later I will store this timestamp in a memory and server will send this back to the client.
my problem in the above code : ConfigureISR (); //when this function is called : It will stop executing further and later it will show an error : Execution is suspended because of error.