RCS file: /usr1/CVS/rtems/cpukit/libmisc/cpuuse/cpuuse.c,v
retrieving revision 1.20
diff -u -r1.20 cpuuse.c
|
|
|
8 | 8 | * found in the file LICENSE in this distribution or at |
9 | 9 | * http://www.rtems.com/license/LICENSE. |
10 | 10 | * |
11 | | * $Id: cpuuse.c,v 1.20 2004/04/17 08:12:01 ralf Exp $ |
| 11 | * cpuuse.c,v 1.20 2004/04/17 08:12:01 ralf Exp |
12 | 12 | * |
13 | 13 | */ |
14 | 14 | |
… |
… |
|
42 | 42 | uint32_t u32_name; |
43 | 43 | char *cname; |
44 | 44 | char name[5]; |
| 45 | uint32_t ival, fval; |
45 | 46 | uint32_t total_units = 0; |
46 | 47 | |
47 | 48 | for ( api_index = 1 ; |
… |
… |
|
61 | 62 | } |
62 | 63 | |
63 | 64 | fprintf(stdout,"CPU Usage by thread\n"); |
64 | | #if defined(unix) || ( CPU_HARDWARE_FP == TRUE ) |
65 | 65 | fprintf(stdout, " ID NAME TICKS PERCENT\n" ); |
66 | | #else |
67 | | fprintf(stdout, " ID NAME TICKS\n" ); |
68 | | #endif |
69 | 66 | |
70 | 67 | for ( api_index = 1 ; |
71 | 68 | api_index <= OBJECTS_APIS_LAST ; |
… |
… |
|
101 | 98 | if ( !isprint(name[2]) ) name[2] = '*'; |
102 | 99 | if ( !isprint(name[3]) ) name[3] = '*'; |
103 | 100 | |
104 | | #if defined(unix) || ( CPU_HARDWARE_FP == TRUE ) |
105 | | fprintf(stdout, "0x%08x %4s %8d %5.3f\n", |
| 101 | ival = total_units ? the_thread->ticks_executed * 10000 / total_units : 0; |
| 102 | fval = ival % 100; |
| 103 | ival /= 100; |
| 104 | fprintf(stdout, "0x%08x %4s %8d %3d.%2.2d\n", |
106 | 105 | the_thread->Object.id, |
107 | 106 | name, |
108 | 107 | the_thread->ticks_executed, |
109 | | (total_units) ? |
110 | | (double)the_thread->ticks_executed / (double)total_units : |
111 | | (double)total_units |
| 108 | ival, |
| 109 | fval |
112 | 110 | ); |
113 | | #else |
114 | | fprintf(stdout, "0x%08x %4s %8d\n", |
115 | | the_thread->Object.id, |
116 | | name, |
117 | | the_thread->ticks_executed |
118 | | ); |
119 | | #endif |
120 | 111 | } |
121 | 112 | } |
122 | 113 | } |