HI all

I am doing a project to develop a high level simulation framework. In the project I need to calculate the number of cycles of a snippet of code in a thread. Like

void func()
{
event1():
int x;
x = x * x;
for();
while();

exec(number_of_cyles)
event2();
}
Here I want to calculate the number of cycles between event1 and event2 and pass these number of cycles to the exec(number_of_cycles) which will later on be simulated. I investigated a number of tools like gprof, Dtrace, linux process statistics, rdstc, getrusage(). None of these seems to be very relevent.

I tried linux process statistics i.e. /proc/<pid>/task/<tid>/stat. I can access the execution time of threads, but all the time I get 0 execution time. What I think that it reads the execution time of threads when it was started. Is there any way to get the updated execution time of thread?

Any help will be highly appreciated.

Irfan