newbie question (how to measure time)

From: dLux (dlux@kapu.hu)
Date: Tue Apr 11 2000 - 11:05:44 EST


Hello!

  I need to measure the time spent in one process, and I need to do
it as exact as possible (about 1us). 2.2.x kernel series, Pentium II
proc.

  My first and not-yet-working solution:
 
  I declared 3 variables in the arch/i386/kernel/process.c:

static pid_t ProcID;
static unsigned long long int RunStart;
static unsigned long long int Elapsed;

  ProcID is the process id, which needs to be profiled. Elapsed is
the time commulated in the process running, RunStart is a temporary
variable.

  I put some additional code to the beginning of the __switch_to in
the arch/i386/kernel/process.c:

        if (prev->pid == ProcID) {
          Elapsed += rdtsc_return()-RunStart;
        } else if (next->pid == ProcID) {
          RunStart = rdtsc_return();
        };

  rdtsc_return() is a function, which returns the Pentium clock in
long long int format.

  These code checks if the process we want to measure is on the
schedule or not.
 
  After it I wanted to write a kernel module, which registered a
file in the /proc, and it can set the ProcID via it, and get the
"Elapsed" value from it.
  The problem is that I don't know how I use that variables.

  I tried this:

extern pid_t ProcID;
extern long long int Elapsed;

  But when I want to use my module, it prints:

or2:/projects/boomerang/timer# insmod timermod.o
timermod.o: unresolved symbol ProcID
timermod.o: unresolved symbol Elapsed

(The timermod.c originally based on the procfs.c file, which is
included in some kernel howto.)

The System.map file in the /usr/src/linux-2.2.13 contains that
symbols:

c021c8c0 b ProcID
c021c8cc b Elapsed

I copied the System.map into /boot/System.map-2.2.13,
/lib/modules/2.2.13, but it doesn't help. Do you know how I can
access those variables?

Another question:
-----------------
Do you know a better and faster way to access that variables? May I
make a device driver for it? Make a syscall? Please refer me to the
URL when I can study these materials.

Thanks for any help in advance,

dLux

--
              God save the screen!

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sat Apr 15 2000 - 21:00:16 EST