Real time interrupts for Pentium 4

A

Thread Starter

akhshay

Hi,

I need to find out the number of instructions executed by my processor per sec.

I wrote a code with 10 simple instructions in a loop. Now I want to sent an interrupt to this program after 1 sec. so that I can count the number of instruction executed per second. How can I set my RTI to 1 sec. and how can I interrupt my program?
 
M

Michael Griffin

I would suggest turning the problem around the other way. Run a set number of loops, and time how long it takes to execute it. Then you just need a
precision timing function. Run the loop with various numbers of iterations so you can extrapolate the timing overhead (assuming this is a linear function).

For timing, the POSIX C documentation states:

NAME

gettimeofday - get the date and time

SYNOPSIS

[XSI] [Option Start] #include <sys/time.h>

int gettimeofday(struct timeval *restrict tp, void *restrict tzp); [Option End]

DESCRIPTION

The gettimeofday() function shall obtain the current time, expressed as seconds and microseconds since the Epoch, and store it in the timeval structure pointed to by tp. The resolution of the system clock is unspecified.

If tzp is not a null pointer, the behavior is unspecified.

RETURN VALUE

The gettimeofday() function shall return 0 and no value shall be reserved to indicate an error.

ERRORS

No errors are defined.
 
Top