![]() |
| | #1 |
| Alessio Stella Join Date: May 2008 Location: Italy, Bologna
Posts: 235
| Net cpu usage of pthreads?! i can measure gross cpu usage by reading special Pentium registers like for instance using opencv functions cvGetTickCount() and cvGetTickFrequency() i can measure net cpu usage by all threads (one process) by using clock() But I don't have currently available functions to measure net cpu usage by one single thread!! |
| mynickmynick is offline | |
| | #2 | |
| Kernel hacker Join Date: Jul 2007 Location: Farncombe, Surrey, England
Posts: 15,686
| Quote:
__________________ Compilers can produce warnings - make the compiler programmers happy: Use them! Please don't PM me for help - and no, I don't do help over instant messengers. | |
| matsp is offline | |
| | #3 |
| Alessio Stella Join Date: May 2008 Location: Italy, Bologna
Posts: 235
| i did not find what i need it's strange |
| mynickmynick is offline | |
| | #4 |
| Kernel hacker Join Date: Jul 2007 Location: Farncombe, Surrey, England
Posts: 15,686
| I'm sure I've worked on this before, but one of your threads have a comment: time measure (net and gross) with pthreads under linux -- Mats
__________________ Compilers can produce warnings - make the compiler programmers happy: Use them! Please don't PM me for help - and no, I don't do help over instant messengers. |
| matsp is offline | |
| | #5 |
| Registered User Join Date: Mar 2003
Posts: 3,844
| |
| Codeplug is offline | |
| | #6 | |
| Alessio Stella Join Date: May 2008 Location: Italy, Bologna
Posts: 235
| Quote: this seems what i was looking for | |
| mynickmynick is offline | |
| | #7 |
| Alessio Stella Join Date: May 2008 Location: Italy, Bologna
Posts: 235
| But unfortunately I found that the required #define _POSIX_THREAD_CPUTIME 0 is 0 in my system so the function clock_gettime () is not supported for a call like Code: #include <time.h>
#include <unistd.h> // for sysconf
int err;
struct timespec t;
if (sysconf(_POSIX_THREAD_CPUTIME)){
err = clock_gettime(CLOCK_THREAD_CPUTIME_ID,&t);
}
|
| mynickmynick is offline | |
| | #8 |
| Alessio Stella Join Date: May 2008 Location: Italy, Bologna
Posts: 235
| but the header posix_opt.h says: Code: /* Clock support in threads must be also checked at runtime. */ #define _POSIX_THREAD_CPUTIME 0 |
| mynickmynick is offline | |
| | #9 |
| Kernel hacker Join Date: Jul 2007 Location: Farncombe, Surrey, England
Posts: 15,686
| Check the return value, it will return some sort of error saying "not supported" if it's not supported, one would assume. -- Mats
__________________ Compilers can produce warnings - make the compiler programmers happy: Use them! Please don't PM me for help - and no, I don't do help over instant messengers. |
| matsp is offline | |
| | #10 |
| Alessio Stella Join Date: May 2008 Location: Italy, Bologna
Posts: 235
| |
| mynickmynick is offline | |
| | #11 | |
| Kernel hacker Join Date: Jul 2007 Location: Farncombe, Surrey, England
Posts: 15,686
| Quote:
-- Mats
__________________ Compilers can produce warnings - make the compiler programmers happy: Use them! Please don't PM me for help - and no, I don't do help over instant messengers. | |
| matsp is offline | |
| | #12 | |
| Alessio Stella Join Date: May 2008 Location: Italy, Bologna
Posts: 235
| Quote: | |
| mynickmynick is offline | |
| | #13 |
| Registered User Join Date: Mar 2003
Posts: 3,844
| >> I found out that it gives a gross value (time elapsed include time used by other threads!!) How did you confirm that? You could also compare the value with what's in /proc/<PID>/task/<TID>/stat, for Linux 2.6 and up. gg |
| Codeplug is offline | |
| | #14 | |
| Alessio Stella Join Date: May 2008 Location: Italy, Bologna
Posts: 235
| Quote:
one main thread one station thread two camera threads (several other threads not measured, but basically idle) the measure given was always the same for all threads (except some difference due to different termination instant) and the same as the value given by Open CV pentium clock measure So despite what said the measure is per process not per thread | |
| mynickmynick is offline | |
| | #15 |
| Alessio Stella Join Date: May 2008 Location: Italy, Bologna
Posts: 235
| Still Looking!! Please other suggestions!! ps with special options gives a net per thread cpu usage so this info should be vailable with some special functions at kernel level?? |
| mynickmynick is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Reduce CPU usage | patrick22 | Windows Programming | 9 | 07-10-2009 02:13 PM |
| questions on multiple thread programming | lehe | C Programming | 11 | 03-27-2009 07:44 AM |
| time measure (net and gross) with pthreads under linux | mynickmynick | Linux Programming | 12 | 12-01-2008 07:39 AM |
| Calculating CPU Usage | vitaliy | Linux Programming | 3 | 08-21-2005 09:38 AM |
| CPU Usage so high | X PaYnE X | Windows Programming | 9 | 12-21-2003 03:07 AM |