LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Get CPU Usage (https://www.linuxquestions.org/questions/programming-9/get-cpu-usage-325909/)

ramicub 05-22-2005 07:35 AM

Get CPU Usage
 
Kernel version 2.4.21-4.ELsmp
Red Hat Enterprise Linux ES release 3 (Taroon)

Using NPTL
I want to calculate the cpu-time of a function in a thread.

I tryed using
ss << "/proc/self/task/" &l;t< gettid() << "/stat";
fd = open(ss.str().c_str(), O_RDONLY);
But there is no such folder task under self

I tryed using
pthread_getcpuclockid(pthread_self(),&clock_id);
clock_gettime(clock_id,&ts);

I get undefined symbol: clock_gettime

Please help
Thanks

eddiebaby1023 05-22-2005 01:54 PM

Re: Get CPU Usage
 
Quote:

Originally posted by ramicub

I tried using
pthread_getcpuclockid(pthread_self(),&clock_id);
clock_gettime(clock_id,&ts);

I get undefined symbol: clock_gettime
Did you #include <time.h>?

ramicub 05-23-2005 01:49 AM

Yes I did include time.h!

premkarat 11-02-2010 04:34 AM

I was looking at a kernel bug and found this thread. The answer to this is you should include pthread.h and use -pthread option while compiling and linking.

For more info, you can refer this.

http://www.kernel.org/doc/man-pages/...clockid.3.html


All times are GMT -5. The time now is 09:00 AM.