LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 05-22-2005, 07:35 AM   #1
ramicub
LQ Newbie
 
Registered: May 2005
Posts: 2

Rep: Reputation: 0
Question 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
 
Old 05-22-2005, 01:54 PM   #2
eddiebaby1023
Member
 
Registered: May 2005
Posts: 378

Rep: Reputation: 33
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>?
 
Old 05-23-2005, 01:49 AM   #3
ramicub
LQ Newbie
 
Registered: May 2005
Posts: 2

Original Poster
Rep: Reputation: 0
Yes I did include time.h!
 
Old 11-02-2010, 04:34 AM   #4
premkarat
LQ Newbie
 
Registered: Feb 2007
Posts: 9

Rep: Reputation: 1
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
getting realtime info on memory usage-cpu and harddrive usage steering Linux - Newbie 5 03-03-2005 08:43 PM
how to determine cpu usage, memory usage, I/O usage by a particular user logged on li rags2k Programming 4 08-21-2004 04:45 AM
Controlling CPU usage & memory usage Saravana babu Linux - Software 0 02-18-2004 05:55 AM
CPU Usage Jehos Programming 3 11-30-2003 05:46 AM
cpu usage Aldebaran Linux - Newbie 3 10-11-2003 11:57 AM


All times are GMT -5. The time now is 01:14 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration